Re: [程式] SAS 抓取同ID不同時段的對象

看板Statistics作者 (咖啡王子)時間5年前 (2018/08/19 10:08), 編輯推噓1(103)
留言4則, 1人參與, 5年前最新討論串2/2 (看更多)
/* try this one */ data score; input ID $ date score; datalines; AAA 1601 50 AAA 1607 40 BBB 1401 60 CCC 1802 70 AAA 1801 40 AAA 1803 30 ; run; data score; set score; year=int(date/100); month=mod(date,100); newdate=mdy(month,1,year); run; proc sql; create table dif6 as select a.id,a.date,b.date as date2,a.score as score1,b.score as score2 /* a.id,a.date,a.score-b.score as dif6 */ from score as a, score as b where a.id=b.id and intck('month',a.newdate,b.newdate)=6; quit; proc sql; create table dif24 as select a.id,a.date,b.date as date2,a.score as score1,b.score as score2 /* a.id,a.date,a.score-b.score as dif24 */ from score as a, score as b where a.id=b.id and intck('month',a.newdate,b.newdate)=24; quit; ※ 引述《say29217074 (:)))))》之銘言: : [軟體程式類別]: : SAS : [程式問題]: : 資料處理 : [軟體熟悉度]: : 新手 : [問題敘述]: : 各位大大好 : 我的資料有三列 : ID 日期 分數 : AAA 1601 50 : BBB 1401 60 : CCC 1802 70 : .. : .. : AAA 1803 30 : ... : ID列是每個申請人的編號 日期是申請時間 分數是申請的分數 : 現在想看每個申請人在第一次申請/六個月後再次申請/24個月後若有再次申請的分數差異 : 但完全沒有頭緒該如何進行 : 不知道有沒有人能提供一下意見 : [程式範例]: : -- -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 111.249.217.10 ※ 文章網址: https://www.ptt.cc/bbs/Statistics/M.1534644521.A.523.html

08/20 10:05, 5年前 , 1F
太神啦 謝謝分享
08/20 10:05, 1F

08/20 10:05, 5年前 , 2F
再研究一下為什麼要把一張table拆成兩個
08/20 10:05, 2F

08/20 10:06, 5年前 , 3F
proc 那段 非常感謝
08/20 10:06, 3F

08/20 10:06, 5年前 , 4F
proc sql
08/20 10:06, 4F
文章代碼(AID): #1RUD4fKZ (Statistics)
文章代碼(AID): #1RUD4fKZ (Statistics)