SAS中文论坛

 找回密码
 立即注册

扫一扫,访问微社区

查看: 1059|回复: 2
打印 上一主题 下一主题

求助 base online tutor里面一个关于loop的问题

[复制链接]

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
楼主
 楼主| 发表于 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.
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
沙发
 楼主| 发表于 2012-3-5 05:46:35 | 只看该作者

Re: 求助 base online tutor里面一个关于loop的问题

两道题的code不完全一样,第二道题有一个output,也就是手动操纵让pdv记得的数据output到dataset。
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
板凳
 楼主| 发表于 2012-3-25 15:06:43 | 只看该作者

Re: 求助 base online tutor里面一个关于loop的问题

没output,某个循环完成后,再赋予year的值,判断循环条件是否成立,不成立则终止循环,此时year的值被写入pdv。
有output,完成一个循环,则写入一个数据集。
解释不太通顺,希望牛牛们给一个能听得懂的解释!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|SAS中文论坛  

GMT+8, 2025-6-4 19:07 , Processed in 0.118245 second(s), 20 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表