楼主: ihust
3362 13

[问答] 剔除缺失值进行运算 [推广有奖]

11
ihust 发表于 2013-1-2 23:35:49
ttklkl 发表于 2013-1-2 20:39
if nmiss(a,b,c,d)=0 then e=a*b*c*d;
关键我的数据是有缺失值的,要所有非缺失值的乘积

12
ihust 发表于 2013-1-14 12:46:13
data tmp;
        retain a 1;
        input x @@;
        if x = . then delete;
         a = a * x;
datalines;
10 . 1 2 3 4
;
run;

13
erzi_yhj 发表于 2013-1-16 13:58:13
Try this codes below, you can have the product of any amount of variables

data temp;
input a b c d e f;
datalines;
1 2 . 3 4 5
2 3 4 5 6 1
. . 3 4 2 1
3 2 3 . 2 1
;
run;

data calculate;
set temp;
array numb(*) _numeric_;
result=1;
do i=1 to dim(numb);
      if numb(i)^=. then result=result*numb(i);
end;
output;
drop i;
run;
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
ihust + 1 + 1 + 1 精彩帖子

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

14
ihust 发表于 2013-1-18 13:33:40
erzi_yhj 发表于 2013-1-16 13:58
Try this codes below, you can have the product of any amount of variables

data temp;
有道理

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-5 19:12