楼主: doreendy
1928 4

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

  • 0关注
  • 0粉丝

初中生

0%

还不是VIP/贵宾

-

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

楼主
doreendy 发表于 2009-3-6 01:33:00 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
<p>在准备SAS BASE的考试, 做123时遇到的这道题, 怎么想都想不通为什么答案是B而不是C. 请高手指点一下. </p><p>A SAS PRINT procedure output of the WORK.LEVELS data set is listed<br/>&gt; below:<br/>&gt; Obs name level<br/>&gt; 1 Frank 1<br/>&gt; 2 Joan 2<br/>&gt; 3 Sui 2<br/>&gt; 4 Jose 3<br/>&gt; 5 Burt 4<br/>&gt; 6 Kelly .<br/>&gt; 7 Juan 1<br/>&gt; The following SAS program is submitted:<br/>&gt; data work.expertise;<br/>&gt; set work.levels;<br/>&gt; if level = . then<br/>&gt; expertise = 'Unknown';<br/>&gt; else if level = 1 then<br/>&gt; expertise = 'Low';<br/>&gt; else if level = 2 or 3 then<br/>&gt; expertise = 'Medium';<br/>&gt; else<br/>&gt; expertise = 'High';<br/>&gt; run;<br/>&gt; Which of the following values does the variable EXPERTISE contain?<br/>&gt; A. Low, Medium, and High only<br/>&gt; B. Low, Medium, and Unknown only<br/>&gt; C. Low, Medium, High, and Unknown only<br/>&gt; D. Low, Medium, High, Unknown, and ' ' (missing character value)<br/>&gt; Answer: B<br/></p>
二维码

扫码加我 拉你入群

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

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

关键词: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
<font face="Courier New" color="#0000ff" size="2"><p>else if level = 2 or 3&nbsp; then<br/>should be <br/>else if level = 2 or level= 3&nbsp; then<font face="Courier New" color="#0000ff" size="2"><font face="Courier New" color="#0000ff" size="2"><font face="Courier New" color="#0000ff" size="2"></font></font><font face="Courier New" color="#0000ff" size="2"></font></font></p></font><font face="Courier New" color="#0000ff" size="2"><font face="Courier New" color="#0000ff" size="2"><font face="Courier New" color="#0000ff" size="2"></font></font><font face="Courier New" color="#0000ff" size="2"></font></font>

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

藤椅
zhitler 发表于 2009-3-6 10:16:00
<p>这是考阅读,不是考编程</p>

板凳
yongyitian 发表于 2009-3-6 13:28:00
<p>这道题考了两点:<br/>1。if 语句中的 or 和 and 的前后应该是两个条件。每一个条件为 true 时 return 1, 为 false 时 return 0。<br/>&nbsp;if level = 2 or 3 then 语句中 or 后面 的 3 is a constant and &gt;0 所以 always 为 ture。 </p><p>2。 if, else if 中条件判断的次序。<br/>&nbsp;if level = . then&nbsp; expertise = 'Unknown';<br/>&nbsp;else if level = 1 then expertise = 'Low';<br/>&nbsp;else if level = 2 or 3 then&nbsp; expertise = 'Medium';<br/>试着把上面的else if 的次序换一下,再看看结果就明白了。<br/>&nbsp;if level = . then&nbsp; expertise = 'Unknown';<br/>&nbsp;else if level = 2 or 3 then&nbsp; expertise = 'Medium';<br/>&nbsp;else if level = 1 then expertise = 'Low';</p>

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

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

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

报纸
Smallworld46890 发表于 2009-3-7 03:07:00
<p>"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&nbsp;will be resolved to 'Medium'. If you put it on top you will only get one result for all the observations: 'Medium'.</p>

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

客服
GMT+8, 2026-12-1 07:43