BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
atijjani
Fluorite | Level 6

Hello,

I need some help with this problem i am trying to solve. I am running a logistic regresssion model. After running the full model, i removed one variable from the full model. I want to see how removing that one variable affected the betas (parameter estimates) of the other variables in the model.

I will be very grateful if i can get an answer to this.

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
atijjani
Fluorite | Level 6

I modified the solution you gave and it worked perfectly well. Thank you so much for your input Reeza.

Below is the complete code for anyone with similar problem:

 

/*1*/
ods table parameterestimates=model1;
proc logistic data=temp;
   class sex race hospital snf;
    model read=sex race hospital snf;
run;

ods table parameterestimates=model2;
proc logistic data=temp;
    class sex race hospital;
    model read=sex race hospital;
run;

proc sort data=model1;
  by variable;

proc sort data=model2;
  by variable;
run;

data comparison;
/*2*/
merge model1 (Rename=estimate=estimate1) 
           model2 (rename=estimate=estimate2);
by variable;
/*3*/
diff=((estimate1-estimate2)/estimate2)*100;
run;

proc print data=comparison;
run;

View solution in original post

7 REPLIES 7
Reeza
Super User

Sorry, It's unclear what your question is. If you have a question on code, please include your current code. 

atijjani
Fluorite | Level 6

Thank you for your response.

Assuming that i have a logisic regression model with the full model below:

 

proc logistic data=temp;
    class sex race hospital snf;
    model read=sex race hospital snf;
run;

 

and then i reduced model as below (it is without the variable snf)

 

proc logistic data=temp;
   class sex race hospital;
   model read=sex race hospital;
run;

 

I want to see how removing snf from the full model changed the betas (parameter estimates) for other variables in the reduced model.

atijjani
Fluorite | Level 6
In other words, i want to check for potential confounding effect of snf.
Reeza
Super User
  1. Capture the parameterEstimates from each table
  2. Merge tables together - rename estimate variable - I can't remember what it's called at the moment. If you don't rename the variable will overwrite and you won't get valid values.
  3. Calculate the difference
/*1*/
ods table parameterestimates=model1;
proc logistic data=temp;
    class sex race hospital snf;
    model read=sex race hospital snf;
run;

ods table parameterestimates=model2;
proc logistic data=temp;
    class sex race hospital snf;
    model read=sex race hospital;
run;

data comparison;
/*2*/
merge model1 (Rename=estimate=estimate1) 
           model2 (rename=estimate=estimate2);
by variable;
/*3*/
diff=estimate1-estimate2;
run;
atijjani
Fluorite | Level 6
Thank you so much. Let me see if it works
atijjani
Fluorite | Level 6

I modified the solution you gave and it worked perfectly well. Thank you so much for your input Reeza.

Below is the complete code for anyone with similar problem:

 

/*1*/
ods table parameterestimates=model1;
proc logistic data=temp;
   class sex race hospital snf;
    model read=sex race hospital snf;
run;

ods table parameterestimates=model2;
proc logistic data=temp;
    class sex race hospital;
    model read=sex race hospital;
run;

proc sort data=model1;
  by variable;

proc sort data=model2;
  by variable;
run;

data comparison;
/*2*/
merge model1 (Rename=estimate=estimate1) 
           model2 (rename=estimate=estimate2);
by variable;
/*3*/
diff=((estimate1-estimate2)/estimate2)*100;
run;

proc print data=comparison;
run;
Ksharp
Super User

Use backward seletion + include= option.

 


data class;
 set sashelp.class;
 if _n_ in (1:9) then y=1;
  else y=0;
run;

proc logistic data=class;
    class sex;
    model y(event='1')= sex age weight height/details selection=backward include=3;
run;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 2509 views
  • 3 likes
  • 3 in conversation