标题: 请教一道SAS base题目 [打印本页] 作者: shiyiming 时间: 2011-6-22 00:59 标题: 请教一道SAS base题目 (123题#111)
A SAS PRINT procedure output of the WORK.LEVELS data set is listed below:
Obs name level
1 Frank 1
2 Joan 2
3 Sui 2
4 Jose 3
5 Burt 4
6 Kelly .
7 Juan 1
The following SAS program is submitted:
data work.expertise;
set work.levels;
if level = . then
expertise = 'Unknown';
else if level = 1 then
expertise = 'Low';
else if level = 2 or 3 then
expertise = 'Medium';
else
expertise ='High';
run;
Which of the following values dose the variable EXPERISE contain?
A. Low, Medium, and High only
B. Low, Medium, and Unknown only
C. Low, Medium, High, and Unknown only
D. Low, Medium, High, Unknown, and ' ' (missing character value)
Answer: B
理解不能啊为什么没有High?果然还是那个else句子出了问题?该怎么理解?作者: shiyiming 时间: 2011-6-26 12:14 标题: Re: 请教一道SAS base题目 if 3总是成立滴,SO不会到之后判断去了作者: shiyiming 时间: 2011-6-28 08:17 标题: Re: 请教一道SAS base题目 This question is as follow: You can see, the statement ' or 3' , it should be or' level=3'. So there is a mistake about this conditional statement, the SAS will stop here. When any observation to be read, it is stop here. Never continue, so you can see that the level=4, never be read by sas. That's it. I am not sure. Please refer to others opinions. Thanks.作者: shiyiming 时间: 2011-9-1 05:30 标题: Re: 请教一道SAS base题目 如果把程序改为:
data work.expertise;
set work.levels;
if level = . then expertise = 'Unknown';
else if level = 1 then expertise = 'Low';
else if level = 2 or level = 3 then expertise = 'Medium'
else expertise ='High';
run;
或者改为:
data work.expertise;
set work.levels;
if level = . then expertise = 'Unknown';
else if level = 1 then expertise = 'Low';
else if level = 2 then expertise = 'Medium';
else if level = 3 then expertise = 'Medium';
else expertise ='High';
run;
都能得到正确的结果。所以,程序的错误应该是出在 else if level = 2 or 3 then expertise = 'Medium' 这一句。作者: shiyiming 时间: 2011-9-12 00:18 标题: Re: 请教一道SAS base题目 so the statement "or 3"is wrong作者: shiyiming 时间: 2011-10-25 15:42 标题: Re: 请教一道SAS base题目 level=2 or 3 等价于 (level=2) or (3) 故恒成立作者: shiyiming 时间: 2011-12-13 10:34 标题: Re: 请教一道SAS base题目 正如上面解释到的原因,在下学习了。