请选择 进入手机版 | 继续访问电脑版
楼主: clark3721
4552 8

[问答] 求助sas adv 130题 [推广有奖]

  • 0关注
  • 0粉丝

大专生

1%

还不是VIP/贵宾

-

威望
0
论坛币
16 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
536 点
帖子
21
精华
0
在线时间
44 小时
注册时间
2008-12-19
最后登录
2016-11-10

clark3721 发表于 2013-5-20 17:24:45 |显示全部楼层 |坛友微信交流群

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
37. The SAS data set ONE contains fifty million observations and contains the variables PRICE, QUANTITY,
FIXED, and VARIABLE.
Which SAS program successfully creates three new variables TOTREV, TOTCOST, and PROFIT and requires the
least amount of CPU resources to be processed?
A.data two;
set one;totrev = sum(price * quantity);totcost = sum(fixed,variable);
if totrev > 1000;
profit = sum(totrev,-totcost);
run;
B.data two;
set one;
totrev = sum(price * quantity);
if totrev > 1000;
totcost = sum(fixed,variable);
profit = sum(totrev,-totcost);
run;

C.data two;
set one;
totrev = sum(price * quantity);
where totrev > 1000;
totcost = sum(fixed,variable);
profit = sum(totrev,-totcost);
run;

D.data two;
set one;
where totrev > 1000;
totrev = sum(price * quantity);
totcost = sum(fixed,variable);
profit = sum(totrev,-totcost);
run;

Answer: B
为什么是B 不是C啊





二维码

扫码加我 拉你入群

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

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

关键词:observations Successfully observation successful Variables resources quantity creates amount profit

boe 发表于 2013-5-20 17:53:50 |显示全部楼层 |坛友微信交流群
where语句在set语句之后执行,此时totrev不存在,程序错误不会执行。
已有 1 人评分论坛币 收起 理由
admin_kefu + 20 热心帮助其他会员

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

Gorgeous girl , I love !

使用道具

clark3721 发表于 2013-5-20 17:58:39 |显示全部楼层 |坛友微信交流群
boe 发表于 2013-5-20 17:53
where语句在set语句之后执行,此时totrev不存在,程序错误不会执行。
where 放在run前面就可以了吧 where 是在input buffer前进行处理,就是说 totrev不存在是吧

使用道具

boe 发表于 2013-5-20 18:10:02 |显示全部楼层 |坛友微信交流群
clark3721 发表于 2013-5-20 17:58
where 放在run前面就可以了吧 where 是在input buffer前进行处理,就是说 totrev不存在是吧
非也。where紧接着set执行,用来过滤数据,sas再执行其他语句。故where中的变量必须存在于现有数据集,而不是那种进一步计算得到的。
Gorgeous girl , I love !

使用道具

clark3721 发表于 2013-5-20 18:29:20 |显示全部楼层 |坛友微信交流群
boe 发表于 2013-5-20 18:10
非也。where紧接着set执行,用来过滤数据,sas再执行其他语句。故where中的变量必须存在于现有数据集,而 ...
我run了下发现where是对one进行筛选的,one里没有这个变量 这才是最主要的原因对吧

使用道具

649west 发表于 2015-11-5 03:11:21 |显示全部楼层 |坛友微信交流群
WHERE statements work on variables that are already in SAS data sets.

run C, then you will get error message.

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.TWO may be incomplete.  When this step was stopped there were 0
         observations and 5 variables.
WARNING: Data set WORK.TWO was not replaced because this step was stopped.


已有 1 人评分论坛币 收起 理由
admin_kefu + 20 热心帮助其他会员

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

使用道具

Tigflanker 发表于 2015-11-12 13:03:52 |显示全部楼层 |坛友微信交流群
where在data步的编译阶段,故where句中的所有字段只能是set句中声明的

使用道具

mandyfervor 发表于 2015-11-13 16:45:40 |显示全部楼层 |坛友微信交流群
where 只是对原始数据中的数据进行筛选的,对计算后的数据筛选就得用if了。
具体看这个解释:

if语句是面向PDV的,对当前PDV中的数据进行判断,满足条件时将其写入到外部数据集;where语句也是面向PDV的,它使用于从外部数据源读数据到PDV之前进行判断,当满足条件时才被写入到PDV。显然一个在写入PDV之前,一个在写入PDV之后,两者是有差异的。
注pdv是program data vector. 不懂的可以看http://web.utk.edu/sas/OnlineTutor/1.2/en/60476/m22/m22_4.htm 这个或者pre guide base的书。里面讲得最清楚。

使用道具

lleiou 发表于 2016-10-30 07:42:31 |显示全部楼层 |坛友微信交流群
楼主的头像好眼熟.

使用道具

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

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

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

GMT+8, 2024-3-29 23:05