Re: [程式] SAS 前後期比較

看板Statistics作者 (安魂曲)時間16年前 (2009/12/06 16:41), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/4 (看更多)
: 依照t大寫法 : Obs P t : 1 2 -1 : 2 2 -1 : 3 2 -1 : 4 5 1 : 5 1 0 : 6 3 1 : 7 2 -1 : 8 3 1 : 第7項就會被判斷成-1 而不是0 想問一下 有可以選擇從P的哪個資料點開始做判斷 : 的方法嘛? 感謝回答 以下是我自己寫出問題要的答案 (感謝k大跟t大之前推文), 只是我在想應該有更簡潔方式寫法才是, 因為用c語言寫判斷式似乎不需要用那麼多! retain d 0 n 0; lagp = lag(p); lag2p = lag2(p); if _n_ =1 then d = p; if (p = d ) then do; if n =0 then t = -1; else goto pp; end; pp: else do; n+1; if p > lagp then t=1; else if p = lag2p then do; if lagp > lag2p then t =1; else t =0; end; else t =0; end; ※ 編輯: RequiemInDm 來自: 218.167.64.56 (12/06 22:31)
文章代碼(AID): #1B6svDod (Statistics)
文章代碼(AID): #1B6svDod (Statistics)