标题: 如何发现缺失值变量并填充? [打印本页] 作者: shiyiming 时间: 2013-7-18 10:21 标题: 如何发现缺失值变量并填充? 比如有个测试数据集如下:
data test;
input x y z m;
cards;
1 . 2 .
2 3 4 5
;
run;
1)想得到所有缺失值的变量的list,上面的数据集应该是y和m;2)对y和m进行均值填充。
如何实现?感谢大侠!作者: shiyiming 时间: 2013-8-9 08:12 标题: Re: 如何发现缺失值变量并填充? [code:o8ljcuhy]data test;
input x y z m;
cards;
1 . 2 .
2 3 4 5
;
run;
proc sql noprint; select name into :var separated by ' ' from dictionary.columns where libname='WORK' and memname='TEST' ;quit;
%macro mm;
data a; set test;
length m_var $ 10;
array aa(4) x y z m;
%do i=1 %to 4;
if missing(aa(&i.)) then m_var=catx(' ',m_var,"%scan(&var.,&i.)") ;
if missing(aa(&i.)) then aa(&i.)=0;
%end;
run;
%mend;
%mm[/code:o8ljcuhy]