SAS缺失值筛选,删除比例超过一定阈值的变量/观测

1.删除缺失值比例超过一定阈值的变量

options symbolgen;
data missing;
input n1 n2 n3 n4 n5 n6 n7 n8 c1$ c2$ c3$ c4$;
datalines;
1 . 1 . 1 . 1 4 a . c .
1 1 . . 2 . . 5 e . g h
1 . 1 . 3 . . 6 . . k l
1 . . . . . . . a b c d
;
data _null_;
if 0 then 
  set missing nobs=obs;
  array num_vars[*] _NUMERIC_;
  array char_vars[*] _CHARACTER_;
  call symputx('num_qty', dim(num_vars));
  call symputx('char_qty', dim(char_vars));
  call symputx('m_obs',obs);
  stop;
run;
%put &num_qty &char_qty &m_obs;
data _null_;
  set missing end=finished;
  array num_vars[*] _NUMERIC_;
  array char_vars[*] _CHARACTER_;
  array num_miss [&num_qty] (&num_qty * 0);
  array char_miss [&char_qty] (&char_qty * 0); 
  length list $ 50; 
  do i=1 to dim(num_vars);
    if num_vars(i) eq . then num_miss(i)+1;
  end;
  do i=1 to dim(char_vars);
    if char_vars(i) eq '' then char_miss(i)+1;
  end;
  if finished then 
  • 1
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值