Re: [程式] SAS分組分年加總
這樣應該可以
/*new 是新的資料名稱*/
/*test 是你原本的資料名稱*/
data test;
input ID SHARES YEAR;
cards;
1 100 2010
1 250 2010
2 332 2010
3 250 2010
1 135 2011
1 270 2011
2 345 2011
2 700 2011
;
run;
proc sql;
create table new as
select sum(shares) as shares,id,year
from test
group by id,year
;
quit;
proc print data=new;
run;
應該就是你想要的結果了
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.168.13.109
→
01/09 22:58, , 1F
01/09 22:58, 1F
討論串 (同標題文章)
完整討論串 (本文為第 2 之 2 篇):
程式
2
3