thanks a lot for your suggestions, the reason is the wrong compelling of the code, but there is another error " ERROR 72-185: The COMPRESS function call has too many arguments.." there is the error in the "backward" section, that is "compress(&varselec,"&var1","t");", please tell m whats wrong with this section, thanks a lot ! there is the entire programme /*varlist--the selected varibale;varcible--the binary response variable (0/1); method = RSPL*/ %macro stepwise(table=,method=,varlist=,varcible=,threshold=,exclude=,type==,random=,include=,varclass=); /*we declare some local variables*/ %let varselec=; %let notconv=0; %let stop=0; %let j=0; %let random1=%str(random intercept / subject=&random solution type=&type;); %let class=%str(class &random &varclass;); /*varclass is the variables of class */ /*FIRST APPROCH FORWARD WE ADD ONE VARIABLE BY STEP*/ /*We do a loop corresponding at each step of variables selection*/ %do %while (&stop=0) ; %let j=%eval(&j+1); %put "STEP &j"; /* create a empty table */ data tested_var; format effect $50. ProbF 4.3; run; %local i var; %let i=0; /*keep one by one variables which remain to test*/ %do %while(%scan(&varlist,&i+1,%str( )) ne %str( )); %let i = %eval(&i+1); %let var=%scan(&varlist,&i,%str( )); /* &varselec : variables already selected in the model &var : variables which remain to test */ ods output Tests3=Tests3(keep=effect ProbF) ; title "Model with the variable &i"; proc glimmix data=&table method=&method; &class; model &varcible(event='1')=&varselec &var/ solution oddsratio link=logit dist=binomial ; &random1; nloptions maxiter=100; run; ods output off; /*keep the P of new variable to test */ data Tests3; set Tests3; nobis=1; run; data Tests3; set Tests3; if last.nobis; by nobis; run; data tested_var; set tested_var Tests3; run; %end; /*we keep the highest P value and then compare it to the threshold (0.05)-----forward*/ data gtgt; set tested_var; if ProbF=. then delete; run; proc sort data=gtgt; by ProbF; run; data apport; set gtgt; by nobis; if first.nobis; run; data fsd; set apport; retain stopper 0; if ProbF>&threshold then stopper=1; else stopper=0; call symput('stop',stopper); call symput('var',effect); call symput('thres',ProbF); run; %if &stop=1 %then %do; %put "Algorithm tell us to stop looking for new variables in the model"; %put "Last variable proposed to be add was &var with a p-value of &thres"; %end; %else %do; %put "Algorithm tell us to continue "; %let newvar=&var; %put "The new variable is &newvar"; %let varselec=&varselec &newvar; %put "Variables selected at step &j are &varselec"; /*-------------------------back ward-----exclude the variable with probF> exclude------------------------------------------ */ /*run model with all selected variabels */ %let stop2=0; %do %while (&stop2=0); %let j = %eval(&j+1); ods output Tests3=Testsb(keep=effect ProbF); proc glimmix data=&table method=&method; &class; model &varcible (event='1')=&varselec / solution dist=binary link=logit oddsratio ; &random1; nloptions maxiter=100; run; /*we remove the worst variable thanks to the p value*/ %let var1=; %let varselec1=; data Testsb; set Testsb; nobis=1; call symput('num',nobis);run; %if &stop2=0 %then %do; proc sort data=Testsb; by descending ProbF; run; data apport1; set Testsb; by nobis ; if first.nobis; run; data fsd1; set apport1; retain stopper 0; if first.ProbF>&exclude then stopper=1; call symput('var1',effect); varselec1=compress(&varselec,"&var1","t"); /*delete the nonsignificant variable */ call symput('varselec1',varselec1); call symput('stop',stopper); run; %end; %if &stop=1 and ¬conv=0 %then %do; %let stop2=1; %put "Algorithm tell us to stop removing for new variables in the model"; %put "Last variable proposed to be remove was &var with a p-value of &thres"; %let varselec=&varselec1; %end; %if &stop=0 and ¬conv=0 %then %do; %let stop2=1; %put "Algorithm tell us to continue finding new variables for the model"; %let varselec=&varselec; %put "The variable dropped is &var1"; %end; %end; /*return to the forward */ /*part to give us the list of variables which remain to test at the next step j+1*/ %let varenplus=; %let i=0; %do %while(%scan(&varlist,&i+1,%str( )) ne %str( )); %let i = %eval(&i+1); %let variable= %scan(&varlist,&i,%str( )); %if &variable ne &newvar %then %do; %let varselection=1; %end; %else %do; %let varselection=0; %end; %if &varselection=1 %then %do; %let varenplus= &varenplus &variable ; %end; %end; /*New list of variables to test at the next step*/ %let varlist=&varenplus; %put "Variables to test at the next step are &varlist"; %end; %end; /*final model */ ods output solutionR=solutionR OddsRatios=OddsRatios(KEEP=ESTIMATE DF LOWER UPPER) Tests3=TESTS(keep=df effect probF) ; proc glimmix data=&table method=&method; &class; model &varcible(event='1')=&varselec / solution oddsratio link=logit dist=binomial ; &random1; nloptions maxiter=100; run; %mend stepwise; /*varlist--the selected variable ;varcible--binary response variable (0/1);method= RSPL*/ /*%macro stepwise(table=,n=,method=,varlist=,varcible=,threshold=,exclude=,type==,random=,include=,varclass=);*/ /*City sex tion agegroup4 cityprop1 education2 marriage medinsure1 Income1 clear service BMI roomnum_person area_person,*/ %stepwise(table=sasuser.new2,method=RSPL,varlist=sex tion agegroup4 cityprop1 education2 marriage medinsure1 Income1 clear service BMI roomnum_person area_person, varcible=ill2,threshold=0.05,exclude=0.1,type=un,random=city,include=,varclass=sex tion agegroup4 cityprop1 education2 marriage medinsure1 Income1 clear service);
... View more