方法一:hash,个人认为是最好的方法,不过不想写了。
方法二:iml,也不错,不过也不想写了。
方法三:macro,一个普遍大众化的方法,就写一下:
%macro a;
data t;
set a;
row=_n_;
run;
%do i=1 %to 3;
data t1 t2;
set t(keep=row a&i);
if a&i=. then output t2;
else output t1;
run;
data t2;
merge t2 b(keep=b&i rename=(b&i=a&i));
run;
data X;
set t1 t2;
by row;
run;
%if &i eq 1 %then %do;
data C;
set X(drop=row);
run;
%end;
%else %do;
data C;
merge C X(drop=row);
run;
%end;
%end;
%mend a;
%a;