问两道SAS Base题目40.The following SAS program is submitted:data work.pieces; do while (n lt 6); n + 1; end; run; What is the value of the variable N in the output data set?A.5 B.6 C.7 D..(missing numeric) Answer:B 为什么答案选B?一开始n没有被定义啊,在do while里n应该是missing啊.你在n+1的时候才被赋值为0的吧……48.Given the raw data file CALENDAR:----|----10---|----20---|----30 01012000 The following SAS program is submitted:data test; infile 'calendar'; input @1 date mmddyy10.; if date = '010
问两道SAS Base题目
40.The following SAS program is submitted:
data work.pieces;
do while (n lt 6);
n + 1;
end;
run;
What is the value of the variable N in the output data set?
A.5
B.6
C.7
D..(missing numeric)
Answer:B
为什么答案选B?一开始n没有被定义啊,在do while里n应该是missing啊.你在n+1的时候才被赋值为0的吧……
48.Given the raw data file CALENDAR:
----|----10---|----20---|----30
01012000
The following SAS program is submitted:
data test;
infile 'calendar';
input @1 date mmddyy10.;
if date = '01012000'd then event = 'January 1st';
run;
What is the value of the EVENT variable?
A.' ' (missing character value)
B..(missing numeric value)
C.January 1st
D.The program fails to execute due to errors.
虽然mmddyy10.的读取长度过长了,但是我在SAS程序上涌datalines的方式试了一下还是能够读取的啊,为什么答案说会有错误?
40.n+1 的话,系统调用的运算方法跟不一样,不是N=N+1;而是N=SUM(N+1);SUM(N+1)的话,虽然一开始N 没有被赋值,但是系统在进行+1操作时,会直接将缺失值的N自动转化为0来计算.所以答案是6;
48.系统报的错误,如果我没想错的话,应该是if date ='01012000'd then event ='January 1st'; 这里句会出错;错误点应该是date ='01012000'd 这里;改成date='01jan2000'd就可以了.SAS不支持'01012000'd这种格式.至于为什么你自己用datalines的方式尝试了可以,我就不知道了.