标题: 跟crakman做sas base认证试题(54) [打印本页] 作者: shiyiming 时间: 2010-11-13 11:37 标题: 跟crakman做sas base认证试题(54) From crackman's blog on Baidu
<p><font size="4">54.Consider the following data step:<br>
<br>
data WORK.TEST;<br>
set SASHELP.CLASS(obs=5);<br>
retain City 'Beverly Hills';<br>
State='California'; <br>
run; <br>
<br>
The computed variables City and State have their values assigned using two different methods, a RETAIN statement and an Assignment statement. Which statement regarding this program is true?</font></p>
<p><br>
<font size="4"> A. The RETAIN statement is fine, but the value of City will be truncated to 8<br>
bytes as the LENGTH statement has been omitted.<br>
B. Both the RETAIN and assignment statement are being used to initialize new<br>
variables and are equally efficient. Method used is a matter of programmer preference.<br>
C. The assignment statement is fine, but the value of City will be truncated<br>
to 8 bytes as the LENGTH statement has been omitted. <br>
D. City's value will be assigned one time, State's value 5 times.</font></p>
<p><font size="4">Answer: D</font></p>
<p><font size="4">本文属于博客:</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">其实这里考察的RETAIN到底是在非执行语句还是执行语句。<br>
RETAIN的作用是初始化变量为“特定的默认值”,是非执行语句,在编译过程中,PDV中用“特定的默认值”替代SAS系统默认值。在DATA步中,加入STATE进入PDV中,STATE='California'; 是赋值语句,也就是执行语句。每一次从SASHELP.CLASS读取数据之后,都要执行一次赋值语句。</font></p>
<p><font size="4">可以用下面的一个示例形容:<br>
1.老板现在想将一批东西搬到仓库里面去,就告诉秘书。一般来说,老板说话都是那么模糊或者不明确,秘书就开始思考老板的意思,咋个搬,按照老板的以前说话的经验,秘书开始布置仓库,老板说要搬东西,东西有五类(对应CLASS里面的5个变量),另外老板说还有一个东西,专门放老板喜欢吃的东西。秘书一想,老板就喜欢吃回锅肉嘛,那么就另外一个类东西就是回锅肉(对应CITY)。秘书开始给每一个存放东西的房间编号,1 2 3 4 5 6,第六个不用搬,每次都是回锅肉,只搬一次搞定,因为秘书都猜到老板的心思了。但是其他六类就不知道了。<br>
2.秘书开始搬东西了,搬完5类东西之后,发现临时来了一个新东西需要放在仓库,只有在现在的仓库里面加一个房间,编号为7,瞧一瞧新东西的大小和样式,选择合适的房间编号为7进行存放这个东西。继续搬,每次搬东西进入这剩下的六个房间,1 2 3 4 5 7。</font></p>
<p> </p> <a href="http://hi.baidu.com/crack%5Fman/blog/item/50dfdd03f419bddd7a894788.html">阅读全文</a>