楼主: qt600
3792 6

[求助]请教Base SAS题目(4.01) [推广有奖]

  • 0关注
  • 1粉丝

本科生

83%

还不是VIP/贵宾

-

威望
0
论坛币
5641 个
通用积分
0.9701
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
1143 点
帖子
98
精华
0
在线时间
77 小时
注册时间
2007-2-25
最后登录
2023-9-11

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币

A SAS PRINT procedure output of the WORK.LEVELS data set is listed below:

Obsname 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 .为什么没有High?

二维码

扫码加我 拉你入群

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

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

关键词:Base following Procedure Character Variable 题目 SAS Base

回帖推荐

cxu07 发表于7楼  查看完整内容

When omitting the dot after the 2, sas ignore the trailing sign and the number, in this case , it is @4. So SAS consider the "2" without the dot as column not the 2 digits of the weight. so it reads the second column number, which is 2. so if substituting the 2 with 3, you get missing value, which is dot, sub 2 with 4, you get 9 and so on.

sumc 发表于2楼  查看完整内容

找了半天,终于弄明白了,这个问题还是很能迷惑人的. 在sas中关于or是这样说明的: Remember that only one comparison in a series of OR comparisons must be true to make a condition true, and any nonzero, nonmissing constant is always evaluated as true (see Boolean Numeric Expressions). Therefore, the following subsetting IF statement is always true: if x=1 or 2; SAS first evaluates X=1, and the result c ...

本帖被以下文库推荐

沙发
sumc 发表于 2007-4-2 09:36:00 |只看作者 |坛友微信交流群

找了半天,终于弄明白了,这个问题还是很能迷惑人的.

在sas中关于or是这样说明的:

Remember that only one comparison in a series of OR comparisons must be true to make a condition true, and any nonzero, nonmissing constant is always evaluated as true (see Boolean Numeric Expressions). Therefore, the following subsetting IF statement is always true:

if x=1 or 2;

SAS first evaluates X=1, and the result can be either true or false; however, since the 2 is evaluated as nonzero and nonmissing (true), the entire expression is true.

因为后面2是一个常数且不为0,所以整个表达式都为真,那么后面都执行同样的操作.

所以如果你的题目想要包含"high",那么应该改为:

~~~

else if level = 2 or level=3 then

expertise =' Medium';

~~~~~~~~~~

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

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

使用道具

藤椅
qt600 发表于 2007-4-3 01:32:00 |只看作者 |坛友微信交流群
依次类推,凡是用Or来连接的这种形式,else 后面的值一律取不到,是吧?

使用道具

板凳
qt600 发表于 2007-4-3 01:37:00 |只看作者 |坛友微信交流群

The following SAS program is submitted:

data test;

set sasuser.employees;

if 2 le years_service le 10 then

amount=1000;

else if years_service gt 10 then

amount=2000;

else

amount=0;

amount_per_year=years_serice/amount;

run;

Which one of the following values does the variable AMOUNT_PER_YEAR contain

if an employee has been with the company for one year?

A. 0

B. 1000

C. 2000

D. . (missing numeric value)

Answer: D.

这道题是不是因为amount=0, 所以整个值才是missing numeric value?

使用道具

报纸
zzheng722 发表于 2007-4-3 05:55:00 |只看作者 |坛友微信交流群

Yes. You are right. 0 不能作分母, 所以商是missing.

使用道具

地板
qt600 发表于 2007-4-3 11:46:00 |只看作者 |坛友微信交流群

The contents of the raw data file SIZE are listed below:

----|----10---|----20---|----30

72 95

The following SAS program is submitted:

data test;

in file 'size';

input@ 1 height 2.@ 4 weight 2;

run;

Which one of the following is the value of the variable WEIGHT in the output data set?

A. 2

B. 72

C. 95

D. . (missing numeric value)

Answer:A
I know the problem is to omit the period.SAS assign a length of 2 to weight instead of reading weight with the 2 informat.
I would like to ask why the value of the variable WEIGHT is 2?

使用道具

7
cxu07 发表于 2007-4-4 21:34:00 |只看作者 |坛友微信交流群

When omitting the dot after the 2, sas ignore the trailing sign and the number, in this case , it is @4.

So SAS consider the "2" without the dot as column not the 2 digits of the weight. so it reads the second column number, which is 2. so if substituting the 2 with 3, you get missing value, which is dot, sub 2 with 4, you get 9 and so on.

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

总评分: 论坛币 + 10   查看全部评分

使用道具

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

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

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

GMT+8, 2024-4-25 06:35