data stats;
set revenue;
array weekly{5} mon tue wed thu fri;
total = weekly{i} * .25;
output;
end;
run;
Which one of the following DO statements completes the program and processes the elements of the WEEKLY array?
A. do i = 1 to 5;
B. do weekly{i} = 1 to 5;
C. do i = mon tue wed thu fri;
D. A DO loop cannot be used because the variables referenced do not end in a digit.
Click Comment link to get answer
A
ReplyDelete?B
ReplyDeleteA is the correct ans
ReplyDeleteA is correct answer
ReplyDeleteWas able to get 'A' to execute, 'B' caused a syntax error...does anyone have a better explanation though? Thanks.
ReplyDeleteWhat explanation do you need? A is the way to do it and B is a syntax error!
ReplyDeleteIt is because you need a do loop to go through it 5 times for the 5 days and call the do lpool 'i'. This can then be referenced later on in 'total = weekly{i} * .25;'
ReplyDeleteHaven't seen a good explanation here. Seems like a, b, or c should work.
ReplyDeleteIs it because we need to do arithmetic?
mon tue wed thu fri are variables' name, are not id numbers so answer "C.do i = mon tue wed thu fri;" is not correct. These 5 variables are grouped in by weekly, we can use weekly{1} which is same as mon, and ditto to other 4 variables.
DeleteIf you like, you can try the following code to understand them better:
data revenue;
input mon tue wed thu fri;
datalines;
1 1.1 1.2 1.3 1.4
2 2.1 2.2 2.3 2.4
;
run;
data stats;
set revenue;
array weekly{5} mon tue wed thu fri;
do i = 1 to 5;
total = weekly{i} * .25;
put weekly{i}= total=;
output;
end;
run;
u r awesome
DeleteA
ReplyDelete