libname ch7 'f:\data_model\book_data\chapt7';
proc sort data=ch7.smooth;by cid month;run;
data smooth;
set ch7.smooth;
by cid;
array lags(12);
lags(1)=lag(balance);
do i=2 to 12;
lags(i)=lag(lags(i-1));
end;
do j=12 to 2 by -1;
if j gt cns then lags(j)=.;
put j=;
end;
if first.cid then do
cns=0;
do i=1 to 12;lags(i)=.;
end;
end;
cns+1;
mean6=mean(of lags1-lags6);
mean12=mean(of lags1 - lags12);
/*drop i j;*/
run;
这段代码求移动平均,我没完全看懂,哪位大侠能解释下在PDV中怎样运行的? if语句为什么不能放到前面,第二个do语句是怎么运行的?谢谢各位? |
|