|
楼主

楼主 |
发表于 2012-3-4 01:20:21
|
只看该作者
求助 base online tutor里面一个关于loop的问题
做测试的时候有两题的答案是矛盾的,不知道怎么回事
第四题说Year的store value是2005,第五题又说这条选项是错误的。两题的code都一样。求帮忙,谢谢!
[b:39btu47p]4. In the data set Work.Invest, what would be the stored value for Year?[/b:39btu47p]
[color=#0000FF:39btu47p]data work.invest;
do year=1990 to 2004;
Capital+5000;
capital+(capital*.10);
end;
run;[/color:39btu47p]
a. missing
b. 1990
c. 2004
d. 2005
Correct answer: d
At the end of the fifteenth iteration of the DO loop, the value for Year is incremented to 2005. Because this value exceeds the stop value, the DO loop ends. At the bottom of the DATA step, the current values are written to the data set.
[b:39btu47p]5. Which of the following statements is false regarding the program shown below?[/b:39btu47p]
[color=#0000FF:39btu47p]data work.invest;
do year=1990 to 2004;
Capital+5000;
capital+(capital*.10);
output;
end;
run;[/color:39btu47p]
a. The OUTPUT statement writes current values to the data set immediately.
b. The stored value for Year is 2005.
c. The OUTPUT statement overrides the automatic output at the end of the DATA step.
d. The DO loop performs 15 iterations.
Correct answer: b
The OUTPUT statement overrides the automatic output at the end of the DATA step. On the last iteration of the DO loop, the value of Year, 2004, is written to the data set. |
|