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

Hi

I have imputed missing values in my dataset by proc mi and wants to provide odds ratios and parameterestimates in seperate datasets on the interaction between a categorical (age, two levels) and continuous (Att24_pa: number of relapses per year) variable. However, when I run proc logistic with an ODDSRATIO statement followed by ods out, I only get datasets with odds ratios and parameterestimates on the variables not included in the interactionterm (here: sex, diseaseDurationYrs and baselineedss). "_mi_fcs_komplet" is the dataset with imputed missing values. So, when I run this model, I get one odds ratio from each level in the age category for the increment in the continuous Att24_pa variable. And I need to output these two estimates with confidence intervals so I can combine them using proc mianalyze, followed by log-transforming, combining again and, finally, back-transformation. Also, I'm not sure whether the proc mianayze statement is correct for interaction terms.

 

This is the code I have used:

 

proc logistic data=_mi_fcs_komplet ;
by _Imputation_; *100 imputations;
class Efficacy (ref='No') age (ref=">=40") sex (ref="2 Female") ;
model Efficacy = age|Att24_pa sex diseaseDurationYrs baselineedss ;
oddsratio att24_pa ; *This is the information I need to be outputted;
ODS OUTPUT PARAMETERESTIMATES=lgsparms ODDSRATIOS=lgsodds;
run;

 

/* Combining the 100 imputations */
proc mianalyze parms(classvar=CLASSVAL )=lgsparms;
class age sex;
modeleffects age|Att24_pa sex diseaseDurationYrs baselineedss;
ODS OUTPUT PARAMETERESTIMATES=mian_ /*lgsparms*/;
run;
*** Log-transform odds ratio estimates and obtain standard error from confidence intervals ***;
*Får dog kun alderseffekten ud her;
DATA lgsodds_t; SET lgsodds(WHERE=(INDEX(EFFECT,"att24_pa")));
log_or_lr_value=LOG(ODDSRATIOEST);
log_or_lr_se=(LOG(UPPERCL)-LOG(LOWERCL))/(2*1.96);
RUN;
*** Combine transformed estimates;
PROC MIANALYZE DATA=lgsodds_t;
ODS OUTPUT PARAMETERESTIMATES=mian_lgsodds_t;
MODELEFFECTS log_or_lr_value;
STDERR log_or_lr_se;
RUN;
*** Back-transform combined values;
DATA mian_lgsodds_bt; SET mian_lgsodds_t;
Estimate_back = EXP(ESTIMATE); *Pooled odds ratio;
LCL_back=Estimate_back*EXP(-1.96*STDERR); *Pooled lower limit;
UCL_back=Estimate_back*EXP(+1.96*STDERR); *Pooled upper limit;
RUN;

 

Any help would be much appreciated.

 

Many Thanks,

Tine

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Did you follow the instructions in the blog post - put ODS TRACE ON before/after your code and after and see what the table name is from the log or output? It's the first step.

You can have multiple ODS OUTPUT statements.

https://statgeeks.wordpress.com/2013/08/

 

Or check the documentation for table names.

https://documentation.sas.com/?docsetId=statug&docsetVersion=15.1&docsetTarget=statug_logistic_detai...

 

Most likely it will be Oddsratios, oddsratiosPL or OddsratiosWALD from the table. 

 


@TineKopp wrote:

Dear Reeza

 

Thank you for the link. However, I have already used the ods output statement so the question is what I should call the output object name in order to output odds ratios from the oddsratio statement. I have managed to output the interaction term, but I still need the odds ratios produced by my statement "oddsratio att24_pa" which is the odds ratio of Att24_pa at age=<40 and Att24_pa at age=>=40.

 

Many thanks,

Tine


 

View solution in original post

6 REPLIES 6
Reeza
Super User

Here's some instructions and explanations on how to capture output that is shown.
https://blogs.sas.com/content/sastraining/2017/03/31/capturing-output-from-any-procedure-with-an-ods...

 


@TineKopp wrote:

Hi

I have imputed missing values in my dataset by proc mi and wants to provide odds ratios and parameterestimates in seperate datasets on the interaction between a categorical (age, two levels) and continuous (Att24_pa: number of relapses per year) variable. However, when I run proc logistic with an ODDSRATIO statement followed by ods out, I only get datasets with odds ratios and parameterestimates on the variables not included in the interactionterm (here: sex, diseaseDurationYrs and baselineedss). "_mi_fcs_komplet" is the dataset with imputed missing values. So, when I run this model, I get one odds ratio from each level in the age category for the increment in the continuous Att24_pa variable. And I need to output these two estimates with confidence intervals so I can combine them using proc mianalyze, followed by log-transforming, combining again and, finally, back-transformation. Also, I'm not sure whether the proc mianayze statement is correct for interaction terms.

 

This is the code I have used:

 

proc logistic data=_mi_fcs_komplet ;
by _Imputation_; *100 imputations;
class Efficacy (ref='No') age (ref=">=40") sex (ref="2 Female") ;
model Efficacy = age|Att24_pa sex diseaseDurationYrs baselineedss ;
oddsratio att24_pa ; *This is the information I need to be outputted;
ODS OUTPUT PARAMETERESTIMATES=lgsparms ODDSRATIOS=lgsodds;
run;

 

/* Combining the 100 imputations */
proc mianalyze parms(classvar=CLASSVAL )=lgsparms;
class age sex;
modeleffects age|Att24_pa sex diseaseDurationYrs baselineedss;
ODS OUTPUT PARAMETERESTIMATES=mian_ /*lgsparms*/;
run;
*** Log-transform odds ratio estimates and obtain standard error from confidence intervals ***;
*Får dog kun alderseffekten ud her;
DATA lgsodds_t; SET lgsodds(WHERE=(INDEX(EFFECT,"att24_pa")));
log_or_lr_value=LOG(ODDSRATIOEST);
log_or_lr_se=(LOG(UPPERCL)-LOG(LOWERCL))/(2*1.96);
RUN;
*** Combine transformed estimates;
PROC MIANALYZE DATA=lgsodds_t;
ODS OUTPUT PARAMETERESTIMATES=mian_lgsodds_t;
MODELEFFECTS log_or_lr_value;
STDERR log_or_lr_se;
RUN;
*** Back-transform combined values;
DATA mian_lgsodds_bt; SET mian_lgsodds_t;
Estimate_back = EXP(ESTIMATE); *Pooled odds ratio;
LCL_back=Estimate_back*EXP(-1.96*STDERR); *Pooled lower limit;
UCL_back=Estimate_back*EXP(+1.96*STDERR); *Pooled upper limit;
RUN;

 

Any help would be much appreciated.

 

Many Thanks,

Tine


 

TineKopp
Fluorite | Level 6

Dear Reeza

 

Thank you for the link. However, I have already used the ods output statement so the question is what I should call the output object name in order to output odds ratios from the oddsratio statement. I have managed to output the interaction term, but I still need the odds ratios produced by my statement "oddsratio att24_pa" which is the odds ratio of Att24_pa at age=<40 and Att24_pa at age=>=40.

 

Many thanks,

Tine

TineKopp
Fluorite | Level 6

Dear Reeza

 

I just found out that the statement ods output OddsRatiosWald=outputdata provides me with oddsratios from the oddsratio statement. The final model should look like this:

 

proc logistic data=_mi_fcs_komplet ;
by _Imputation_; *100 imputations;
class Efficacy (ref='No') age (ref=">=40") sex (ref="2 Female") ;
model Efficacy = age|Att24_pa sex diseaseDurationYrs baselineedss ;
oddsratio att24_pa ; 
ODS OUTPUT PARAMETERESTIMATES=lgsparms ODDSRATIOS=lgsodds;

ODS OUTPUT OddsRatiosWald=orw;*These are the odds ratios from the oddsratio statement;

run;

 

Another solution could be to use dummyvariables for the interaction terms. That work just as well!

 

Many thanks,

Tine

Reeza
Super User

Did you follow the instructions in the blog post - put ODS TRACE ON before/after your code and after and see what the table name is from the log or output? It's the first step.

You can have multiple ODS OUTPUT statements.

https://statgeeks.wordpress.com/2013/08/

 

Or check the documentation for table names.

https://documentation.sas.com/?docsetId=statug&docsetVersion=15.1&docsetTarget=statug_logistic_detai...

 

Most likely it will be Oddsratios, oddsratiosPL or OddsratiosWALD from the table. 

 


@TineKopp wrote:

Dear Reeza

 

Thank you for the link. However, I have already used the ods output statement so the question is what I should call the output object name in order to output odds ratios from the oddsratio statement. I have managed to output the interaction term, but I still need the odds ratios produced by my statement "oddsratio att24_pa" which is the odds ratio of Att24_pa at age=<40 and Att24_pa at age=>=40.

 

Many thanks,

Tine


 

TineKopp
Fluorite | Level 6

Yes, thank you! And as I just wrote. If you dont know which table name to use, make dumme variables instead. That gives the same results.

 

Best whishes,

Tine

 

Reeza
Super User
Only in this particular example, in general for output the approach above works on any type of output from SAS PROCS.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 2326 views
  • 0 likes
  • 2 in conversation