不懂你的比较是什么意思,我就写了个计算概率的,你看看相应的部分自行修改吧!
%macro pan;
%do i=1 %to 96;
data data&i (keep=y x1-x10);
array x x1-x10;
do i=1 to 1000;
y=(ranuni(-1)<0.3);
do j=1 to 10;
x(j)=rannor(-1);
end;
output;
end;
run;
%end;
%mend;
%pan;
%macro stanley;
%do i=1 %to 47;
data ana;
set data&i - data%eval(&i+47);
run;
ods output ParameterEstimates=para;
proc logistic data=ana;
model y=x1-x10;
run;
data _null_;
set para end=end;
length form $200.;
retain form;
if _n_=1 then form=compress("("||Estimate||")");
else form=compress("("||Estimate||"*"||variable||")+"||form);
if end then call symput("form",form);
run;
%put &form; /*Extract the formular from the logistic regression*/
data comp;
set data%eval(&i+48);
rst=1-1/(1+exp(&form)); /*Calculate the probability of each record*/
run;
%end;
%mend;
%stanley;
|