Re: [程式] SAS資料處理問題

看板Statistics作者 (談無慾)時間9年前 (2015/05/07 20:19), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
※ 引述《ooorrrzzz (orz)》之銘言: : [軟體程式類別]: : SAS : [程式問題]: : 資料處理 : [軟體熟悉度]: : 中(3個月到1年) : [問題敘述]: : 請問我有資料格式如下 : date id score : 201301 001 60 : 201302 001 80 : 201303 001 70 : 201301 002 50 : 201302 002 100 : 請問我要把每個id中,date的資料補到201412 : score的資料則是沿用曾出現過的最後一筆資料 : 僅用id 001舉例 : ex: date id score : 201301 001 60 : 201302 001 80 : 201303 001 70 : 201304 001 70 : 201305 001 70 : 201306 001 70 : ... ... ... : 201412 001 70 懶人解法 proc sort data=test out=test; by id; run; data A1; set test; by id; if last.id then delete; run; data B1; set test; by id; if last.id then OUTPUT; run; data B2; set B1; do i=1 to intck('month',date,'01dec2014'd); date=intnx('month',date,1,'same'); output; end; drop i ; run; DATA FINAL; SET A1 B1 B2; RUN; -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.174.247.130 ※ 文章網址: https://www.ptt.cc/bbs/Statistics/M.1431001188.A.ECD.html
文章代碼(AID): #1LIrXaxD (Statistics)
文章代碼(AID): #1LIrXaxD (Statistics)