data _null_;
start=1;
end=2;
do until(range(start,end) le 0.0001);
y1=log(start)+start-1.5;
temp=(start+end)/2;
y2=log(temp)+temp-1.5;
y3=log(end)+end-1.5;
if y1*y2<0 then do; end=temp;end;
else if y1*y3<0 then do;start=temp;end;
put y1=;
put y2=;
put y3=;
put start=;
put temp=;
put end=;
end;
final_value=(start+end)/2;
put start=;
put end=;
put final_value;
run;
菜鸟想问 为什么这里的else if后面是y1*y3而不是y2*y3,我都试过,两个结果是一样的,但是,要是我写,我肯定写y2*y3,为什么姚老师用y1*y3呢??