2. 如果变量=0则变为缺失值,不参与计算,则可以用
if a>0 then a1=1/(a*a);else a1=.;
if b>0 then b1=1/(b*b);else b1=.;
...
if f>0 then f1=1/(f*f); else f1=.;
index=sum(of a1-f1);
可能这办法有点笨。作者: shiyiming 时间: 2005-2-28 18:55 标题: 借助数组! 可以借助数组来实现!
为使用方便,把变量名改为x1,x2,~,x5,设temp为初始数据集
data temp1;
set temp;
array x{5} x1-x5;
y=0;
do i=1 to 5;
if x(i)=0 then x(i)=.;
y+(1/x(i))^2;
end;
run;