SAS Certified Adv Programmer 130 Questions (19)
The SAS data set TEMP has the following distribution of values for variable A:
A Frequency
1 500,000
2 500,000
6 7,000,000
8 3,000
Which one of the following SAS programs requires the least CPU time to be processed?
A.
data new; set temp; if a = 8 then b = ‘Small’; else if a in(1, 2) then b = ‘Medium’; else if a = 6 then b = ‘Large’; run;
B.
data new; set temp; if a in (1, 2) then b = ‘Medium’; else if a= 8 then b = ‘Small’; else if a = 6 then b = ‘Large’; run;
C.
data new; set temp; if a = 6 then b = ‘Large’; else if a in (1, 2) then b = ‘Medium’; else if a=8 then b = ‘Small’; run;
D.
data new; set temp; if a = 6 then b = ‘Large’; if a in(1, 2) then b = ‘Small’; run;
Topics:
SAS Adv Questions |
5 Comments »
C
Please explain
C. Efficient SAS programming instructs to code in descending order of frequency
To rob roy:
For best performance, you always check the conditions in descending frequency order.
You can reference page 746 on prep guide.
if you are checking conditions in if statement, put the condition first in IF statement that has a chance to occur more frequently.so that we can eliminate no of further checks.