标题: 问两道Sas Base 50题里的题目 [打印本页] 作者: shiyiming 时间: 2010-9-11 22:56 标题: 问两道Sas Base 50题里的题目 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
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的方式试了一下还是能够读取的啊,为什么答案说会有错误?作者: shiyiming 时间: 2010-9-12 18:50 标题: Re: 问两道Sas Base 50题里的题目 供参考,不一定对
1 n确实是在do while的第一次循环中被累加语句赋值为1的,此前它是missing value, 但这不影响while条件的判断, missing value确实小于6
2 一个问题是出在'01012000'd上, 日期常量要写成'01jan2000'd或者是input('01012000',ddmmyy8.); 另外如果用yymmdd10.,需要配合使用truncover作者: shiyiming 时间: 2010-9-12 23:09 标题: Re: 问两道Sas Base 50题里的题目 to hopewell
很有道理啊,谢谢你!作者: shiyiming 时间: 2010-9-16 12:21 标题: Re: 问两道Sas Base 50题里的题目 to hopewell
In sum statement, initial value of the variable is 0 rather than missing. The following should show this.
data _null_;
put a=;
a+1;
put a=;
run作者: shiyiming 时间: 2012-7-13 22:17 标题: Re: 问两道Sas Base 50题里的题目 [quote="ergoudan":2ydwpdxd]to hopewell
In sum statement, initial value of the variable is 0 rather than missing. The following should show this.
data _null_;
put a=;
a+1;
put a=;
run[/quote:2ydwpdxd]
对头,the little sas book和sas base certification pre guide都是这样说的。