楼主: L_SAS
1102 2

求教一个adv 机经题 [推广有奖]

  • 0关注
  • 0粉丝

高中生

82%

还不是VIP/贵宾

-

威望
0
论坛币
92 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
2493 点
帖子
14
精华
0
在线时间
55 小时
注册时间
2016-4-12
最后登录
2018-8-26

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币

我写的

dataProduct;


inputProduct_id Product;


datalines;


1 1001


2 1002


3 1003


;



dataSales;


inputProduct_id Sales;


datalines;


3 100


1 200


5 100


1 200


3 100


1 100


;


以下我copy机经上的code,


Proc sql;


Select p.product,s.totalsales


From product as p


left join (


select sum(sales)as totalsales


from sales as s)


onp.product_id=s.product_id;


quit;


不能得到以下结果。


Whatis the output?


Answer:


ProductTotalsales


1001500


1002.


1003 200


406  Proc sql;


407  Select p.product, s.totalsales


408  From product as p


409  left join (


410  select sum(sales) as totalsales


411  from sales as s)


412  on p.product_id=s.product_id;


ERROR: Column totalsales could not be found in the table/viewidentified with the correlation


       name S.


413  quit;


NOTE:The SAS System stopped processing this step because of errors.


NOTE:PROCEDURE SQL used (Total process time):


      real time           0.01 seconds


      cpu time            0.01


二维码

扫码加我 拉你入群

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

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

关键词:correlation identified Processing left join Procedure

沙发
5傻小不点 发表于 2016-4-28 11:25:07 |只看作者 |坛友微信交流群
稍微改了一下:data product;
input product_id product;
datalines;
1 1001
2 1002
3 1003
;

data sales;
input product_id sales;
datalines;
3 100
1 200
5 100
1 200
3 100
1 100
;

proc sql;
select p.product,totalsales
from product as p
left join (
select sum(sales) as totalsales
from sales as s
group by product_id
)
on p.product_id=s.product_id;
quit;

使用道具

藤椅
L_SAS 发表于 2016-5-3 21:39:38 |只看作者 |坛友微信交流群
Thanks a lot for your kindness. I could not figure out what was wrong before.

使用道具

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

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

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

GMT+8, 2024-4-27 13:25