|
8#

楼主 |
发表于 2006-3-21 22:11:17
|
只看该作者
请各位多多指教!
初学,需要大家的鼓励, <!-- s:D --><img src="{SMILIES_PATH}/icon_biggrin.gif" alt=":D" title="Very Happy" /><!-- s:D -->
分两个部分来处理:
1,连续执行logistic 回归,得到自变量的估计系数, 它是定义在一个数据文件(estimator)中;
2,用estimator对预测数据预测出因变量的预测值;
这里将用来估计的和预测的数据分成两个数据文件来处理。
%macro product(aa=,bb=);
proc sql;
create table c as
select intercept as intercept, x1*y1 as z1 %do i=2 %to 8;,x&i*y&i as z&i %end;
from &aa,&bb;
quit;
%mend;
%macro logistic(data=,dv=,iv=,num=,dnum=,test=);
/* data means what you want do satatistical test on*/
/* dv and iv means dependent variable and independent variables*/
/* dnum is used to specify how many dependant variables includes, like
/*x1 x2 x3...x8, where there are 8 variable and setting dnum=8*/
/* test is dataset, based on which you get predicted yi.*/
data _null_;
iv2 = tranwrd(compbl("&iv"), " ", "+");
dv2 = tranwrd(compbl("&dv"), " ", "+");
call symput('iv2', iv2); /* independant variables array, like weight len...'*/
call symput('dv2', dv2);
run;
%do i=1 %to &dnum;
%let dvv&i=%scan(&dv2,&i,+);
%end;
%do i=1 %to #
%let ivv=%scan(&iv2,&i,+);
proc logistic data=&data outest=estimates;
/* estimated coefficienct stored on dataset estimates;*/
model &ivv=&dvv1-&&dvv&dnum /selection=forward;
run;
data estimates(keep=&dvv1-&dvv2,intercept);
set estimates;
run;
/* keep coefficient for dv and intercept in dataset estimates;*/
%product(aa=estimates,bb=test);
proc sql;
create table y&i as
select z1+z2+z3+z4+z5+z6+z7+z8 as y;
/* where there should be on simplied expression instead of z1+...z8*/
from c;
quit;
%end;
%mend;
Any commets are welcome. thanks a lot! |
|