楼主: mandyfervor
1544 1

[问答] adv 130中37 关于least cpu usage的 [推广有奖]

  • 0关注
  • 0粉丝

已卖:1份资源

本科生

34%

还不是VIP/贵宾

-

威望
0
论坛币
3271 个
通用积分
2.2236
学术水平
5 点
热心指数
5 点
信用等级
5 点
经验
1378 点
帖子
67
精华
0
在线时间
83 小时
注册时间
2015-8-24
最后登录
2023-9-4

楼主
mandyfervor 发表于 2015-11-2 19:35:49 |AI写论文
10论坛币
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
prep guide中726有提到
A WHERE statement and a subsetting IF statement make different use of the program
data vector. The WHERE statement selects observations before they are loaded into the
program data vector, which results in a savings in CPU operations. The subsetting IF
statement loads each observation sequentially into the program data vector. If the
subsetting condition is true, the observation is processed and is written to the output page
buffer.


也就是说应该选C啊,为什么正确答案是B, 是不是在这种情况where不可用?多谢啦

最佳答案

johnpark1 查看完整内容

I always only use where as a dataset option, i.e.Data two; Set one (where=(...)); There is an article online saying 'where' controls input buffer and 'if' controls output buffer. I guess in this example because the where statement is used on a calculated field, it would not really do any subsetting of imput observations.
关键词:usage Least East Sage Age least resources quantity creates amount

沙发
johnpark1 发表于 2015-11-2 19:35:50
I always only use where as a dataset option, i.e.Data two;
Set one (where=(...));

There is an article online saying 'where' controls input buffer and 'if' controls output buffer. I guess in this example because the where statement is used on a calculated field, it would not really do any subsetting of imput observations.

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-3 13:48