SAS Certified Adv Programmer 50 Questions (42)
The SAS data set One consists of five million observations and has 25 variables. Which one of the following SAS programs requires the least CPU time to be processed?
a.
data two; set one; if year(date)=1999 and state in ('NY' 'NJ' 'CT') then sales=sales98*1.1; else if year(date)=2000 and state in ('NY' 'NJ' 'CT') then sales=sales98*1.15; else if year(date)=2001 and state in ('NY' 'NJ' 'CT') then sales=sales98*1.2; run;
b.
data two; set one; if year(date)=1999 and state in ('NY' 'NJ' 'CT') then sales=sales98*1.1; if year(date)=2000 and state in ('NY' 'NJ' 'CT') then sales=sales98*1.15; if year(date)=2001 and state in ('NY' 'NJ' 'CT') then sales=sales98*1.2; run;
c.
data two; set one; if state in ('NY' 'NJ' 'CT')then do; year=year(date); if year=1999 and state in('NY' 'NJ' 'CT') then sales=sales98*1.1; if year=2000 and state in('NY' 'NJ' 'CT') then sales=sales98*1.15; if year=2001 and state in('NY' 'NJ' 'CT') then sales=sales98*1.2 end; run;
d.
data two; set one; if state in('NY' 'NJ' 'CT') then do; year=year(date); select(year); when(1999) sales=sales98*1.1; when(2000) sales=sales98*1.15; when(2001) sales=sales98*1.2; otherwise; end; end; run;
Topics:
SAS Adv Questions |
1 Comment »
D