作者thomas2005 (无)
看板Statistics
标题Re: [程式] SAS取LAG问题
时间Thu Apr 25 18:18:46 2013
自己回答一下。
用 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