上面这样的数据,对应每个com的每个not missing x之间,我需要求y的mean median std min max以及last y,前面几个比较好办,对应每个x可以给个flag然后proc means就可以了。但是最后求last y我有点晕,因为直接用last.flag,可能最后一个y是missing的,那么这时候我要的是最接近的前面的y,这要如何处理?
data temp(drop=temp_y);
retain temp_y;
set raw;
by com;
temp_y=ifn(missing(lag(y)),temp_y,lag(y));
if not first.com and missing(y) then y=temp_y;
if x;
run;[/code:mx45mwiv]