楼主: cxu07
2537 5

SAS base question, Help [推广有奖]

  • 0关注
  • 0粉丝

大专生

70%

还不是VIP/贵宾

-

威望
0
论坛币
735 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
16440 点
帖子
17
精华
0
在线时间
107 小时
注册时间
2007-3-7
最后登录
2022-8-27

楼主
cxu07 发表于 2008-7-11 03:17:00 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币

Questions:

1. 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 summited:
Data work.expertise;
set work.levels;
if level = . then expertise ="Unkown';
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

why no 'high'  and Burt 4 is evaluted to 'Medium' after run the result?

2. A frequency report of the variable Jobcode in the Work.Actors data set is listed
below.
Jobcode Frequency Percent Cumulative
Frequency Cumulative
Percent
Actor I   2  33.33  2  33.33
Actor II  2  33.33  4  66.67
Actor III 2  33.33  6  100.00

Frequency Missing = 1

The following SAS program is submitted:
data work.joblevels;
set work.actors;
if jobcode in ('Actor I', 'Actor II') then
   joblevel='Beginner';
if jobcode='Actor III' then
   joblevel='Advanced';
else joblevel='Unknown';
run;
Which of the following represents the possible values for the variable joblevel in the
Work.Joblevels data set?
a. Advanced and Unknown only
b. Beginner and Advanced only
c. Beginner, Advanced, and Unknown
d. ' ' (missing character value)

Answer A

Why no 'Beginner'? Please help to explain, thanks.

[此贴子已经被作者于2008-7-11 3:19:35编辑过]

二维码

扫码加我 拉你入群

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

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

关键词:SAS base question Quest Base Help SAS Base Help question

沙发
eco-china 发表于 2008-7-11 20:10:00

The second one:

the first if-then statement is useless in this code, because the following if-then-else statement has a trash-bin else statement which puts everything other than 'advanced' to 'unkonwn'.

藤椅
eco-china 发表于 2008-7-11 20:15:00

The first One:

The key is to understand the following code:

if level = 2 or 3 then expertise = 'Medium';
The colored one is always true, because 3 is always greater than 1, therefore, regardless of the value of level, level = 2 or 3 is always '1' which is true. That makes everything to be 'medium'.

I didnot find out the answer at first place. I tried every possible codes in SAS, and finally found out the solution.

Thanks for your asking. It helps me too.

板凳
cxu07 发表于 2008-7-11 21:57:00

Thank you for answering my question and you used smart way to get the solution for first one. Great Job!

I am still confusing a little about the second one. Suppose we put a "else" in the second if-than statment, then the result would include "Beginner"?  If this is true, it helps a lot to understand the question. If this true, so we could say, if we meet similar question we can do same thing and ignore the first if-then statment?

Thanks.

报纸
SignPingGu 发表于 2008-7-12 02:45:00
To the second one:

The original code:
if jobcode in ('Actor I', 'Actor II') then joblevel='Beginner';
if jobcode='Actor III' then joblevel='Advanced';
else joblevel='Unknown';

In Data Step, after the first if-then statement, the second if-then statement still deal with the same observation. You are right, if you put 'else' before the second if-statement, you will keep the 'Beginner'.

地板
cxu07 发表于 2008-7-12 07:19:00
Thank you all guys, this helped a lot.

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-16 12:37