楼主: doreendy
1393 4

[求助]SAS BASE 的一道题 [推广有奖]

  • 0关注
  • 0粉丝

初中生

0%

还不是VIP/贵宾

-

威望
0
论坛币
50 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
142 点
帖子
9
精华
0
在线时间
0 小时
注册时间
2007-7-1
最后登录
2010-2-4

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

在准备SAS BASE的考试, 做123时遇到的这道题, 怎么想都想不通为什么答案是B而不是C. 请高手指点一下.

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 does the variable EXPERTISE 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

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:SAS base Base following Character Procedure 求助 SAS Base

回帖推荐

yongyitian 发表于4楼  查看完整内容

这道题考了两点:1。if 语句中的 or 和 and 的前后应该是两个条件。每一个条件为 true 时 return 1, 为 false 时 return 0。 if level = 2 or 3 then 语句中 or 后面 的 3 is a constant and >0 所以 always 为 ture。 2。 if, else if 中条件判断的次序。 if level = . then  expertise = 'Unknown'; else if level = 1 then expertise = 'Low'; else if level = 2 or 3 then  expertise ...

本帖被以下文库推荐

沙发
yongyitian 发表于 2009-3-6 04:41:00 |只看作者 |坛友微信交流群

else if level = 2 or 3  then
should be
else if level = 2 or level= 3  then

[此贴子已经被作者于2009-3-6 4:44:32编辑过]

使用道具

藤椅
zhitler 发表于 2009-3-6 10:16:00 |只看作者 |坛友微信交流群

这是考阅读,不是考编程

使用道具

板凳
yongyitian 发表于 2009-3-6 13:28:00 |只看作者 |坛友微信交流群

这道题考了两点:
1。if 语句中的 or 和 and 的前后应该是两个条件。每一个条件为 true 时 return 1, 为 false 时 return 0。
 if level = 2 or 3 then 语句中 or 后面 的 3 is a constant and >0 所以 always 为 ture。

2。 if, else if 中条件判断的次序。
 if level = . then  expertise = 'Unknown';
 else if level = 1 then expertise = 'Low';
 else if level = 2 or 3 then  expertise = 'Medium';
试着把上面的else if 的次序换一下,再看看结果就明白了。
 if level = . then  expertise = 'Unknown';
 else if level = 2 or 3 then  expertise = 'Medium';
 else if level = 1 then expertise = 'Low';

[此贴子已经被作者于2009-3-6 13:34:58编辑过]

已有 1 人评分经验 论坛币 收起 理由
bakoll + 3 + 3 精彩帖子

总评分: 经验 + 3  论坛币 + 3   查看全部评分

使用道具

"if level=2 or 3" means if level=2 or if 3, so this condition is always true, anything comes after it and does not meet all the previous conditions will be resolved to 'Medium'. If you put it on top you will only get one result for all the observations: 'Medium'.

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-5-1 10:11