- data test;
- input x @@;
- cards;
- . . 1 2 . 3 . . 5
- ;
- run;
- proc sql noprint;
- select x into: x2
- from test where x~=.;
- quit;
- data t(keep=x);
- set test;
- retain x1;
- retain flag;
- if x~=. and flag=0 then do; flag=1;end;
- if _n_=1 and x=. then flag=0;
- if x=. and flag=0 then %do; x=&x2; %end;
- else
- if flag=1 and x~=. then x1=x;
- else x=x1;
- run;
实际上我的方法用了宏,我想应该有直接用data步可以实现的做法……但是我没想出来,恳请各位大侠们解答一下~谢谢~