Re: [程式] SAS取LAG問題

看板Statistics作者 (無)時間11年前 (2013/04/25 18:18), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/4 (看更多)
自己回答一下。 用 SAS 範例 sample code 就可以。 來源: http://0rz.tw/ptdbO /* Reset COUNT at the start of each new BY-Group */ if first.start then count=1; /* On each iteration, set to missing array elements */ /* that have not yet received a lagged value for the */ /* current BY-Group. Increase count by 1. */ do i=count to dim(x); x(i)=.; end; count + 1; run; : 延用一下這標題。 : 目前有一個資料分組取 lag 的疑問想請教一下各位。 : 我爬文過找到 11768 這篇,其實問題跟我要問的一樣。 : 只是我的要取到 12 or n 期,文章推文最後 tew 大所說的。 : 就是我目前想知道的問題。 : "tew:要不要延伸思考 取5期落後期的語法要如何寫" : 想請大家指點一下。 : 謝謝。 : 以下資料以分成 id 分成兩組,我想對每個組 lag 3 次後取值。 : id beta return : 1 3 . : 1 4 . : 1 5 . : 1 6 3 : 1 7 4 : 2 8 . : 2 11 . : 2 9 . : 2 4 8 : 2 10 11 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.117.232.110
文章代碼(AID): #1HUGC8cI (Statistics)
文章代碼(AID): #1HUGC8cI (Statistics)