看板 Statistics 關於我們 聯絡資訊
[軟體程式類別]: SAS [程式問題]: 關於特定年度相乘問題 [軟體熟悉度]: 新手 [問題敘述]: https://i.imgur.com/VzCjCiY.jpg
[程式範例]: 我希望能將每家com 於2015-2018年間的do*ipo相乘後加總起來,並新增一欄顯示。 例如:2015的do與ipo相乘為1*1=1,2015年算到2018年為1+1+1+1=4,另外想將這個結果新 增一欄位為man,顯示 剛剛加總後的數字大於等於1,則man為1,否則為0。 因為我希望每家com特定年間去做計算 不太曉得語法要如何寫 在麻煩各位 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 111.82.96.202 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Statistics/M.1651424419.A.BCD.html
wieldthewave: proc sort data=d1 05/02 15:23
wieldthewave: by com 05/02 15:23
wieldthewave: run 05/02 15:23
wieldthewave: data d2 05/02 15:23
wieldthewave: set d1 05/02 15:23
wieldthewave: by com 05/02 15:23
wieldthewave: di = do*ipo 05/02 15:24
wieldthewave: retain man 05/02 15:24
wieldthewave: if first.com then man=di 05/02 15:24
wieldthewave: else man=man+di 05/02 15:24
wieldthewave: where year >= 2015 & year<= 2018 05/02 15:24
wieldthewave: run 05/02 15:24
wieldthewave: 這樣應該ok 試試看吧 05/02 15:24