全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
4134 6
2007-04-01

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?

二维码

扫码加我 拉你入群

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

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

全部回复
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';

~~~~~~~~~~

二维码

扫码加我 拉你入群

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

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

2007-4-3 01:32:00
依次类推,凡是用Or来连接的这种形式,else 后面的值一律取不到,是吧?
二维码

扫码加我 拉你入群

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

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

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?
二维码

扫码加我 拉你入群

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

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

2007-4-3 05:55:00

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

二维码

扫码加我 拉你入群

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

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

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?

二维码

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群