全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1498 1
2015-11-02
悬赏 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.
二维码

扫码加我 拉你入群

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

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

全部回复
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.
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群