SAS中文论坛

 找回密码
 立即注册

扫一扫,访问微社区

查看: 891|回复: 0
打印 上一主题 下一主题

跟crakman做sas base认证试题(40)

[复制链接]

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
楼主
 楼主| 发表于 2010-11-12 17:26:32 | 只看该作者

跟crakman做sas base认证试题(40)

From crackman's blog on Baidu


               
                <p><br>
<font size="4">40.The following SAS program is submitted:<br>
<br>
data WORK.PRODUCTS;<br>
&nbsp;&nbsp;  Prod=1;<br>
&nbsp;&nbsp;  do while(Prod LE 6); <br>
&nbsp;&nbsp;&nbsp;&nbsp;  Prod + 1;<br>
&nbsp;&nbsp;  end;<br>
run; <br>
<br>
What is the value of the variable Prod in the output data set?</font></p>
<p><font size="4">&nbsp;&nbsp;&nbsp;&nbsp;  A. 6 <br>
&nbsp;&nbsp;&nbsp;&nbsp;  B. 7 <br>
&nbsp;&nbsp;&nbsp;&nbsp;  C. 8 <br>
&nbsp;&nbsp;&nbsp;&nbsp;  D. . (missing numeric) <br>
<br>
Answer: B<br>
本文属于博客:</font><a href="http://hi.baidu.com/crack_man/home"><font size="4"><!-- m --><a class="postlink" href="http://hi.baidu.com/crack_man/home">http://hi.baidu.com/crack_man/home</a><!-- m --></font></a><font size="4"> 版权归作者所有,欢迎转载!如有转载,请务必注明出处!未经本文作者同意</font></p>
<p><font size="4">不得用于商业应用。</font></p>
<p><font size="4">这道题考察的是DO WHILE语句中循环执行条件的判断时点。<br>
到底是先判断再执行还是先执行在判断?<br>
DO WHILE是先判断然后执行,也就是说PROD=1,先判断 PROD LE 6是否为TRUE,然后决定是否执行循环语句。<br>
循环每次执行完,PROD自动加1,也就是当PROD LE 6的为TRUE时,PROD最大值就是6,超过6就不执行循环内的语句,就是PROD加1了,</font></p>
<p><font size="4">但是PROD等于6的时候,依然要执行循环,LE就是小与等于的意思。所以最终PROD=7。</font></p>
<p><font size="4">如果改成:<br>
data WORK.PRODUCTS;<br>
&nbsp;&nbsp;  Prod=1;<br>
&nbsp;&nbsp;  do until(Prod LE 6); <br>
&nbsp;&nbsp;&nbsp;&nbsp;  Prod + 1;<br>
&nbsp;&nbsp;  end;<br>
run;<br>
那么PROD=2,为什么等于2?<br>
因为DO UNTIL是执行后再判断,PROD执行一次之后变成2,2 LE 6是true,所以终止执行!。UNTIL里面的表达式是循环终止的判断条件</font></p>
<p><font size="4">,如果UNTIL里面为真,那么就终止执行DO LOOP;而WHILE的表达式是循环继续的判断条件,为真继续执行DO LOOP。</font></p>
<p><font size="4">英文解释:<br>
The DO UNTIL statement executes statements in a DO loop repetitively until a condition is true, checking the </font></p>
<p><font size="4">condition after each iteration of the DO loop. The DO WHILE statement evaluates the condition at the top of the loop; </font></p>
<p><font size="4">the DO UNTIL statement evaluates the condition at the bottom of the loop. </font></p>
<p> </p>
<p> </p> <a href="http://hi.baidu.com/crack%5Fman/blog/item/5ae2f4fed9fba7ceb58f31d7.html">阅读全文</a>
               
                <br/><b>类别:</b><a href="http://hi.baidu.com/crack%5Fman/blog/category/%B8%FAcrackman%D7%F6sas%20base%C8%CF%D6%A4%CA%D4%CC%E2">跟crackman做sas base认证试题</a>&nbsp;<a href="http://hi.baidu.com/crack%5Fman/blog/item/5ae2f4fed9fba7ceb58f31d7.html#comment">查看评论</a>
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-2-3 14:45 , Processed in 0.066861 second(s), 20 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

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