Re: [程式] SAS如何挑選特定資料

看板Statistics作者 (歐吉桑留學生)時間14年前 (2010/02/24 22:29), 編輯推噓5(500)
留言5則, 2人參與, 最新討論串3/3 (看更多)
※ 引述《wlsherica (Mon_tresor)》之銘言: : data a; : input ID DATE EST; : cards; : 0001 20071220 1.1 : 0001 20071115 1.2 : 0001 20071018 1.0 : 0001 20070918 1.3 : 0002 20071220 2.9 : 0002 20071220 2.6 : 0002 20071115 2.8 : 0002 20070911 2.5 : ; : run; : data b; : set a; : retain n 0; : n=n+1; : if ID^=lag(ID) then n=1; : *if n<4 then output; : run; 你的資料要先sort哩 如果確定資料已經排序好了 那不用那麼麻煩 <改一下> data a; set a; by id; if first.id then n=1; else n+1; if n le 3; run; -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.167.180.164

02/24 22:34, , 1F
推~~~~
02/24 22:34, 1F

02/24 22:38, , 2F
不過只有出現ID=1的前三筆耶
02/24 22:38, 2F

02/24 23:03, , 3F
因為寫錯了
02/24 23:03, 3F
※ 編輯: liton 來自: 118.167.180.164 (02/24 23:09)

02/24 23:12, , 4F
學到了^^
02/24 23:12, 4F

02/24 23:39, , 5F
retain n;
02/24 23:39, 5F
文章代碼(AID): #1BXJVR-L (Statistics)
文章代碼(AID): #1BXJVR-L (Statistics)