楼主: djxboywssyds
1219 4

请高人帮忙看一道SAS BASE题目 [推广有奖]

  • 1关注
  • 0粉丝

大专生

55%

还不是VIP/贵宾

-

威望
0
论坛币
6 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
589 点
帖子
32
精华
0
在线时间
29 小时
注册时间
2012-2-8
最后登录
2023-4-15

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
如题,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,以下
是程序:
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;
那么请问,最后在OUTPUT DATASET中应该是first和last两个观测值还是first到last一共四个观测值啊???如果是两个观测值的话怎样改这个程序才可以变成四个观测值啊????谢谢啦
二维码

扫码加我 拉你入群

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

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

关键词:SAS base Base observations observation Variables within 程序

已有 1 人评分经验 收起 理由
crackman + 40 鼓励积极发帖讨论

总评分: 经验 + 40   查看全部评分

沙发
yuerqieqie 发表于 2013-5-11 05:01:53 |只看作者 |坛友微信交流群
应该对每个region输出两个观测值。salary最大的那个和salary最小的那个

使用道具

藤椅
yuerqieqie 发表于 2013-5-11 05:03:10 |只看作者 |坛友微信交流群
改成下面code,就该输出4个了
data one;
set sashelp.prdsale;
retain temp;
by region descending salary;
if first.region then
do;
temp=salary;
end;
if last.region then
do;
range=salary-temp;
end;
run;
已有 1 人评分经验 收起 理由
crackman + 20 鼓励积极发帖讨论

总评分: 经验 + 20   查看全部评分

使用道具

板凳
zhy12212728 发表于 2013-5-11 13:43:23 |只看作者 |坛友微信交流群
我正准备考试,应该比较清晰吧,程序输出每个region的第一个和最后一个观测值,分别是salary最大和最小值。
data one;
set sashelp.prdsale;
retain temp;
by region descending salary;
if first.region then
do;
temp=salary;
output;
end;
else if last.region then
do;
range=salary-temp;
output;
end;else do;
……
output;
end;
run;
do语句内容可以自己写。
已有 1 人评分经验 收起 理由
crackman + 20 鼓励积极发帖讨论

总评分: 经验 + 20   查看全部评分

使用道具

报纸
xhe1117 发表于 2014-12-16 12:42:48 来自手机 |只看作者 |坛友微信交流群
应该对每个region输出两个观测值。salary最大的那个和range

使用道具

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

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

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

GMT+8, 2024-4-27 13:35