求助:如何编写正负标准偏差和变异系数的程序,我这里编写一个请大家帮忙改改,这个好像算出来和Excel的与差别,应该出错了。
变异系数的是
data standarderr;
qb=10;
a=0;
m=0;
sum=0;
do i=1 to qb by 1;
input x@@;
sum=sum+x;
drop sum;
ave=sum/qb;
x2=x-ave;
m=(ave-x)**2+m;
min=sqrt(m)/qb;
drop x2;
end;
cv=min/ave;
output;
cards;
32.9 26.3 39.9 33.6 39.6 27 49.2 49.9 53.8 48
;
proc print;
run;
正负偏差的是:
data standarderr;
qb=32;
a=0;
m=0;
n=0;
sum=0;
do i=1 to qb by 1;
input x@@;
sum=sum+x;
drop sum;
end;
ave=sum/qb;
do i=1 to qb by 1;
input x @@;
x2=x-ave;
if x2<0
then m=(ave-x)**2+m;
else n=(ave-x)**2+n;
if x2<0
then a=a+1;
drop i qb x2;
min=sqrt(m)/a;
max=sqrt(n)/(qb-a);
end;
output;
cards;
5.432
5.088
5.854
5.648
5.361
5.585
5.97
4.988
6.125
6.121
6.292
5.552
6.095
5.789
5.457
6.135
4.724
4.893
5.274
5.489
5.151
5.254
6.549
6.179
6.768
6.971
6.579
6.146
5.672
5.837
6.15
6.422
5.432
5.088
5.854
5.648
5.361
5.585
5.97
4.988
6.125
6.121
6.292
5.552
6.095
5.789
5.457
6.135
4.724
4.893
5.274
5.489
5.151
5.254
6.549
6.179
6.768
6.971
6.579
6.146
5.672
5.837
6.15
6.422
;
proc print;
run;
请大家多多指教