|
|
沙发

楼主 |
发表于 2009-8-20 22:40:51
|
只看该作者
Re: 求教:如何求得某一变量为特定值时另一变量上下一定范围内的观测值?
[code:169uual6]data raw;
input a b;
datalines;
2 0
1 0
2 0
5 1
7 0
9 0
6 0
7 0
4 1
6 0
;
%macro lag(inds,outds,m,n);
options mprint nosymbolgen;
data &outds;
set &inds;
id=_n_;
%do i=&m %to 1 %by -1;
m&i=lag&i(a);
%end;
run;
proc sort data=&outds;
by descending id ;
run;
data &outds;
set &outds;
%do i=1 %to &n;
n&i=lag&i(a);
%end;
run;
proc sort data=&outds out=&outds(drop=id where=(b=1));
by id ;
run;
%mend;
%lag(raw,temp,3,3)[/code:169uual6] |
|