楼主: qt600
3375 4

[原创博文] [求助]ADV SAS 的两道题 [推广有奖]

  • 0关注
  • 1粉丝

已卖:2704份资源

本科生

83%

还不是VIP/贵宾

-

威望
0
论坛币
5641 个
通用积分
0.9701
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
1143 点
帖子
98
精华
0
在线时间
77 小时
注册时间
2007-2-25
最后登录
2023-9-11

楼主
qt600 发表于 2008-4-21 16:37:00 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
Question: 1The SAS data set TEMP has the following distribution of values for variable A:

A
Frequency
1
500,000
2
500,000
6
7,000,000
8
3,000

Which one of the following SAS programs requires the least CPU time to be processed?

A.data new; set temp;
if a = 8 then b = 'Small ';
else if a in(1, 2) then
b = 'Medium';
else if a = 6 then
b = 'Large'; run;

B. data new;
set temp;
if a in (1, 2) then
b = 'Medium';
else if a = 8 then
b = 'Small';
else if a = 6 then
b = 'Large'; run;

C. data new;
set temp;
if a = 6 then b = 'Large ';
else if a in (1, 2) then
b = 'Medium';
else if a = 8 then
b = 'Small';

D. data new;
set temp;
if a = 6 then
b = 'Large ';
if a in (1, 2) then
b = 'Small';  run;

Answer: C Q2.
which one of the following SAS program successfully creates three new variables TOTREV, TOTCOST, and FROFIT and requried the least CPU time to be precessed?



data two;
set one;


totrev = sum (price *quantity);


totcost = sum (fixed, variable);


profit = sum (totrev,otcost);


if totrev>1000;


run;





data two;
set one;


totrev = sum (price *quantity);


if totrev>1000;


totcost = sum (fixed, variable);


profit = sum (totrev,otcost);


run;





data two;
set one;


totrev = sum (price *quantity);


where totrev>1000;


totcost = sum (fixed, variable);


profit = sum (totrev,otcost);


run;





data two;
set one;


where totrev>1000;


totrev = sum (price *quantity);


totcost = sum (fixed, variable);


profit = sum (totrev,otcost);


run;





Answer: B


请大家帮忙分析一下。谢谢。

[此贴子已经被angelboy于2008-4-24 14:35:45编辑过]

二维码

扫码加我 拉你入群

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

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

关键词:Successfully distribution successful following Processed following programs values least

沙发
yue6181 发表于 2008-4-22 00:40:00

第一题,C没有run;程序没有运行不占用时间吧。

第二题,C,D语法错误,A需要先计算完totcost = sum (fixed, variable);

profit = sum (totrev,otcost); 才if, 运行时间应该比B长。

个人意见哦

藤椅
蜻蜓点水 发表于 2008-4-22 03:18:00

Question 1:

if/then/else-->The most efficient way: Check the most frequently occurring condition first, and continue checking conditions in descending order of frequency.

 

Question 2:

A WHERE statement tests the condition before an observation is read into the SAS program data vector (PDV). Hence C and D is wront 'coz variable totrev does not exist before it is processed and created.

 

B is more efficient than A 'coz in B the if-statement is put on the top which means that the if statement process less data.

 


板凳
qt600 发表于 2008-4-22 11:08:00
谢谢两位的高见。收益匪浅。

报纸
dingxuewen 发表于 2009-9-12 07:14:42
三楼回答的精辟,赞!

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

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