请教师父后写的,供参考:
data a;
do j=1 to 400000;
do i=1 to 12;
a=ranuni(4545)*100;
output;
end;
end;
drop i;
run;
proc transpose data=a out=b;
by j;
run;
data c;
set b;
COL_ratio=sum(of COL1-COL12)/COL1;
x1=0;x2=20;
do until (abs(x1-x2)<=0.000001);
y1=x1+x1**2+x1**3+x1**4+x1**5+x1**6+x1**7+x1**8+x1**9+x1**10+x1**11+x1**12-COL_ratio;
temp=(x1+x2)/2;
y2=temp+temp**2+temp**3+temp**4+temp**5+temp**6+temp**7+temp**8+temp**9+temp**10+temp**11+temp**12-COL_ratio;
y3=x2+x2**2+x2**3+x2**4+x2**5+x2**6+x2**7+x2**8+x2**9+x2**10+x2**11+x2**12-COL_ratio;
if y1*y2<0 then do; x2=temp;end;
else if y1*y3<0 then do;x1=temp;end;
/* x0=x1;*/
/* x1=x0-COL_ratio;*/
/* x1=((1-x0**12)/((1-x0)-COL_ratio))/(12*(x0**11)/(1-x0)+(x0**12)/((1-x0)**2))-x0;*/
end;
final_value=(x1+x2)/2;
run;