考虑缺失值的情况
*间隔的天数;
%let interval=2;
data a;
input code day event x;
datalines;
1 03 0 3.3
1 04 1 -4
1 05 1 18
2 01 0 6
2 02 0 4
2 03 1 7
;
run;
proc sql;
create table result as
select code,day,event,x,
(select std(x)
from a t2
where t2.code=t1.code and t2.day<t1.day and t2.day>=t1.day-&interval)
*(case (exists (select 1 from a t3 where t3.code=t1.code and t3.day=t1.day-&interval))
when 0 then . else 1 end)
as mean_&interval._includemissing
from a t1
where event=1
;
quit;


雷达卡
京公网安备 11010802022788号







