全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
3496 6
2017-04-14
Item 26 of 63 Mark item for review
Given the following SAS data sets:
WORK.VISIT1 WORK.VISIT2
Id Expense Id Cost
--- ------- --- ----
001 500 001 300
001 400 002 600
003 350
The following result set was summarized and
consolidated using the SQL procedure:
Id Cost
--- ----
001 300
001 900
002 600
003 350
Which of the following SQL statements was
most likely used to generate this result?
A.
select
Id,
sum(Expense) label='COST'
from WORK.VISIT1
group by 1
union all
select
Id,
sum(Cost)
from WORK.VISIT2
group by 1
order by 1,2
;
B.
select
id,
sum(expense) as COST
from
WORK.VISIT1(rename=(Expense=Cost)),
WORK.VISIT2
where VISIT1.Id=VISIT2.Id
group by Id
order by
Id,
Cost
;
C.
select
VISIT1.Id,
sum(Cost) as Cost
from
WORK.VISIT1(rename=(Expense=Cost)),
WORK.VISIT2
where VISIT1.Id=VISIT2.Id
group by Id
order by
Id,
Cost
;
D.
select
Id,
sum(Expense) as Cost
from WORK.VISIT1
group by Id
outer union corr
select
Id,
sum(Cost)
from WORK.VISIT2
group by Id
order by 1,2

亲测,此题选A; B,C两项错在 Order by 没有指定 ID COST是来自哪个table的;
                        D 错在加了 corr 选择项表明会displays all column that in comman plus 那些并非两个数据集都存在的column;
                              outer union corr 等价于 data set 步的 merge by 语句;词句若无 corr 选择项则 是争取选项。




二维码

扫码加我 拉你入群

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

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

全部回复
2017-4-14 09:56:39
更正,若 语句无corr,同时 将第二个query改为  select id, sum(cost) as cost from data2 group by id 则会有正确结果
二维码

扫码加我 拉你入群

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

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

2017-4-14 09:59:39
liushui 发表于 2017-4-14 09:56
更正,若 语句无corr,同时 将第二个query改为  select id, sum(cost) as cost from data2 group by id 则会 ...
当select 后面跟着两个 table确就要明确指定每个变量来自哪个table;
二维码

扫码加我 拉你入群

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

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

2017-4-14 10:11:21
第54题;
%let name1=shoes;
%let name2=clothes;
%let root=name;
%let suffix=2;
%put &&&root&suffix;
解析:第一轮:macro processor scan && 后,解析为&,然后scan &root 解析为name,再scan &suffix 解析为2,结果为&name2
         第二轮:解析 &name2为 clothes;
补充,若 多加一个& 即 %put &&&&root&suffix时
         第一轮:macro processor scan && 解析为&, 再scan &&解析为&,接着root不变, 再scan &suffix 解析为2,结果为&&root2;
         第二轮:&&变为&,root2不变了,结果为&root2;
         第三轮:SAS提示WARNING: 没有解析符号引用 ROOT2。   %put &&&&root&suffix;               &root2

二维码

扫码加我 拉你入群

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

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

2017-4-14 10:16:14
Item 56 of 63 Mark item for review
The SAS data set WORK.ADDRESSES contains
the email addresses of The XYZ Corporation's
customers in a variable named Email_Address.
The following DATA step is submitted:
data _null_;
set WORK.ADDRESSES;
[_insert_statement_]
put "filename mail email '" Email_Address "'; ";
put "data _null_;";
put " file mail;";
put " put 'Thank you for your continued';";
put " put 'support of The XYZ Corporation.';";
put " put 'We appreciate your patronage.';";
put " put 'Sincerely,';" ;
put " put 'The XYZ Corporation';";
put "run;" ;
run;
Which statement completes the program
and creates a SAS program file?
A.
infile "c:\email.sas";
B.
output "c:\email.sas";
C.
file "c:\email.sas";
D.
None of the above.

记住规则:inflie input是读入,其中inflie指定路径,input指定内容;
                 file  put 是读出,file指定路径,put指定内容。
二维码

扫码加我 拉你入群

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

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

2018-5-23 22:59:41
感谢讲解!清楚易懂 哈哈哈
二维码

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

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