SAS中文论坛

标题: 请教一道sas base题目 [打印本页]

作者: shiyiming    时间: 2012-9-2 19:28
标题: 请教一道sas base题目
1901 2
1905 1
1910 6
1925 .
1941 1
the following sas program is submitted and reference the raw data above:
data coins;
infile 'file';
input year quantity;
<insert statement here>
run;
which one of the following complete the program and produce a nonmissing value for the variable Totalquantity in the last observation of the output dataset?

A. totalquantity+quantity;
B. totalquantity=sum(totalquanity+quantity);
C. totalquantity 0;
sum totalquantity;
D. retain totalquantity 0;
totalquantity=totalquantity+quantity;
答案是A。可我觉得A和D是等价的。我看书上说A语句等价于
retain totalquantity 0;
totalquantity=sum(totalquantity,quantity);
上面这句话不就是D选项的第二个语句吗?
作者: shiyiming    时间: 2012-9-3 12:57
标题: Re: 请教一道sas base题目
我懂了好像。因为在a=a+b的情况下,如果a或b出现missing value,那么a的值就为missing. 但sum语句自动忽略missing值




欢迎光临 SAS中文论坛 (http://www.mysas.net/forum/) Powered by Discuz! X3.2