Question: 1The 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';
D. data new;
set temp;
if a = 6 then
b = 'Large ';
if a in (1, 2) then
b = 'Small'; run;
Answer: C Q2.
which one of the following SAS program successfully creates three new variables TOTREV, TOTCOST, and FROFIT and requried the least CPU time to be precessed?
data two;
set one;
totrev = sum (price *quantity);
totcost = sum (fixed, variable);
profit = sum (totrev,otcost);
if totrev>1000;
run;
data two;
set one;
totrev = sum (price *quantity);
if totrev>1000;
totcost = sum (fixed, variable);
profit = sum (totrev,otcost);
run;
data two;
set one;
totrev = sum (price *quantity);
where totrev>1000;
totcost = sum (fixed, variable);
profit = sum (totrev,otcost);
run;
data two;
set one;
where totrev>1000;
totrev = sum (price *quantity);
totcost = sum (fixed, variable);
profit = sum (totrev,otcost);
run;
Answer: B
请大家帮忙分析一下。谢谢。
[此贴子已经被angelboy于2008-4-24 14:35:45编辑过]