Re: [程式] SAS分組分年加總

看板Statistics作者 (朝右邊鋒邁進)時間13年前 (2011/01/06 20:11), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串2/2 (看更多)
這樣應該可以 /*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
謝謝:0
01/09 22:58, 1F
文章代碼(AID): #1D9R5st6 (Statistics)
文章代碼(AID): #1D9R5st6 (Statistics)