SAS中文论坛

 找回密码
 立即注册

扫一扫,访问微社区

查看: 5194|回复: 2
打印 上一主题 下一主题

SAS Base 50题一问,请高手指点!!

[复制链接]

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
楼主
 楼主| 发表于 2007-10-20 08:13:13 | 只看该作者

SAS Base 50题一问,请高手指点!!

11. The SAS data set SASHELP.PRDSALE contains the variables REGION and SALARY with 4
observations per REGION. SASHELP.PRDSALE is sorted primarily by REGION and within REGION
by SALARY in descending order.
The following SAS program is submitted:
data one;
set sashelp.prdsale;
retain temp;
by region descending salary;
if first.region then
do;
temp = salary;
output;
end;
if last.region then
do;
range = salary - temp;
output;
end;
run;
What is the number of observation(s) written to the output data set for each region?
A. 0
B. 1
C. 2
D. 4

请问为什么选C?

16. The following program is submitted:
data numrecords;
infile cards dlm = ',';
input agent1 $ agent2 $ agent3 $;
cards;
jones,,brownjones,spencer,brown
;
run;
What is the value for the variable named AGENT2 in the second observation?
A. brown
B. spencer
C. ' ' (missing character value)
D. There is no value because only one observation is created.

请问为什么选D?有人给出解释:There is no double trail sign @@ in ‘INPUT’ statements.可是我还是不明白??请大牛指点,谢先!!!!
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
沙发
 楼主| 发表于 2007-10-23 22:29:11 | 只看该作者

Re: SAS Base 50题一问,请高手指点!!

第一题:
主要是if first.region和if last.region的缘故,当对每个分组中的第一个和最后一个处理时进行output,由于程序中显式的使用output,所以本来在数据步结束前的隐式的output不在存在。
第二题:
显而易见是没有第二个observation的,input是一条记录一条记录进行处理的,如果没有使用@或@@,那么数据步中每个input(每一次数据步循环)其实都占据一条记录,不管它是否用完这一条。建议看看@和@@的用法就知道了。
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
板凳
 楼主| 发表于 2007-10-24 00:14:46 | 只看该作者

Re: SAS Base 50题一问,请高手指点!!

Thanks!!!
回复 支持 反对

使用道具 举报

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

本版积分规则

QQ|小黑屋|手机版|Archiver|SAS中文论坛  

GMT+8, 2026-2-4 10:31 , Processed in 0.067745 second(s), 20 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表