标题: 求助 base online tutor里面一个关于loop的问题 [打印本页] 作者: shiyiming 时间: 2012-3-4 01:20 标题: 求助 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.作者: shiyiming 时间: 2012-3-5 05:46 标题: Re: 求助 base online tutor里面一个关于loop的问题 两道题的code不完全一样,第二道题有一个output,也就是手动操纵让pdv记得的数据output到dataset。作者: shiyiming 时间: 2012-3-25 15:06 标题: Re: 求助 base online tutor里面一个关于loop的问题 没output,某个循环完成后,再赋予year的值,判断循环条件是否成立,不成立则终止循环,此时year的值被写入pdv。
有output,完成一个循环,则写入一个数据集。
解释不太通顺,希望牛牛们给一个能听得懂的解释!