SAS缺失值筛选
删除比例超过一定阈值的变量/观测可以参考我的这篇:
https://blog.csdn.net/qq_43211866/article/details/93494359
两种方法
1.data方法
data missing(drop=i);
set data; *此处为自己的数据
array a _numeric_;
do i=1 to dim(a);
if missing(a) then output;
end;
array b _character_;
do i=1 to dim(b);
if missing(b) then output;
end;
转自经管之家by:glxfgsh
http://bbs.pinggu.org/thread-2586128-1-1.html
2.宏
(同时可以填充)
%macro missing(data);
data aa;
set &data;
array arr1{*} _NUMERIC_ ;
array arr2{*} _CHARACTER_ ;
do i = 1 to dim(arr1);
if missing(arr1(I)) then do;
arr1(i)=0; /*这里的arr1(i)=0;根据自己的需要,要0就是0也可以是别的值*/
end;
if missing(arr1(i)) then do;
arr1(i)=0;
end;
do i = 1 to dim(arr2);
if missing(arr2(I)) then do;
arr2(i)="0";
end;
run;
%mend;
data填入自己的数据
转自公众号: 屁屁的sas数据分析
https://mp.weixin.qq.com/s/NO26F96Gm_YZvE0Q7ap6Eg
(这个小姐姐写的东西都很实用!我爱)
以上代码待调试,先记录一下!
和sas一比,我真是太喜欢R了;)