全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1205 2
2016-04-28

我写的

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


二维码

扫码加我 拉你入群

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

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

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

扫码加我 拉你入群

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

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

2016-5-3 21:39:38
Thanks a lot for your kindness. I could not figure out what was wrong before.
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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