楼主: 龙潭丰乐
2837 8

[程序分享] sas求缺失值的三中方法 [推广有奖]

  • 14关注
  • 4粉丝

讲师

50%

还不是VIP/贵宾

-

威望
0
论坛币
6 个
通用积分
0
学术水平
25 点
热心指数
29 点
信用等级
14 点
经验
8652 点
帖子
458
精华
0
在线时间
466 小时
注册时间
2011-11-20
最后登录
2022-1-6

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

方法一:(利用数组求缺失值)

data quan(keep= k);

set quan.cydc;

array x _numeric_;

  do i=1 to dim(x);

   if x(i)=. then j+1;

   end;

   if _n_>1 then k=dif1(j);

   run;

proc print data=quan;

run;

方法二:(转置方法用过程步求缺失值)

proc transpose data=quan.BAIPU out=quan;

var X1-X10;

run;

proc means data=quan nmiss;

  var COL1-COL10;

  output out=quan1nmiss=miss1;

  run;

方法三:(转置后用sql求缺失值)

proc transpose data=quan.BAIPU out=quan;

var X1-X10;

run;

proc sql;

  select nmiss(col1)as miss1,nmiss(col2)asmiss2

  from quan;

  quit;


这些都是比较简单的程序,希望大牛们跟帖高级程序。


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:缺失值 Transpose proc sql numeric output sql

沙发
tangliang0905 发表于 2013-1-19 00:32:26 |只看作者 |坛友微信交流群
how about using functions (NMISS & CMISS) directly?
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
Tigflanker + 1 + 1 + 1 很有启示!

总评分: 学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

使用道具

藤椅
bobguy 发表于 2013-1-19 07:54:20 |只看作者 |坛友微信交流群
It is always better to use existing SAS functions. See  the example below

data t1;
    array p(*) p1-p10;
   do i=1 to 5;
      do j=1 to dim(p);
            if ranuni(123)>=0.5 then p(j)=.;
                else p(j)=1;
          end;
        output;
        end;
        drop i j;
run;

data t2;
  set t1;
  array x _numeric_;
  n_miss=nmiss(of x(*));
run;

proc print;run;
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
Tigflanker + 1 + 1 + 1 醉了。。

总评分: 学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

使用道具

板凳
龙潭丰乐 学生认证  发表于 2013-1-19 09:09:53 |只看作者 |坛友微信交流群
bobguy 发表于 2013-1-19 07:54
It is always better to use existing SAS functions. See  the example below

data t1;
表示长见识了

使用道具

报纸
jingju11 发表于 2013-1-19 11:21:34 |只看作者 |坛友微信交流群
Contrast to traditional way to delete missing values in the model, some procedures in sas start a new algorithm called Full Information Maximum Likelihood to take advantage of residual information after missing. in this case, sas will describe how the missing values are distributed in the data, which is much more advanced than we do it manually as above. for examples, the SEM model in SAS.
JingJu

使用道具

地板
kittyforever 发表于 2013-1-21 09:35:24 |只看作者 |坛友微信交流群
学习了

使用道具

7
天堂之路 发表于 2013-3-21 17:15:44 |只看作者 |坛友微信交流群
不错的分析啊

使用道具

8
geniusv 发表于 2013-3-21 23:05:21 |只看作者 |坛友微信交流群
假设num表示数字变量的空值总数,char表示字符变量的空值总数,all表示总空值数
num+cmiss(of _numeric_);
char+cmiss(of _character_);all+cmiss(of _all_);
最后一行就是总数了
如果想单看每行的空值数,请把加号改成等号。

使用道具

9
chinaeu 发表于 2013-10-10 00:07:25 |只看作者 |坛友微信交流群
好好好

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-27 13:57