SAS缺失值筛选

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了;)

  • 0
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值