The MVMODELS macro has some nice formatting capabilities for producing forest plots from a multivariable logistic regression. However I am unable to add interaction terms like I can with just running proc logistic.
https://communities.sas.com/t5/SAS-Communities-Library/MVMODELS-a-Macro-for-Survival-and-Logistic-Analysis/ta-p/635217#U635217
The macro code for MVMODELS exports parameterestimates from proc logistic, but I have limited expertise with macro coding. Is there a method to alter the MVMODEL code so that I can enter the interaction terms according to sex*race or sex|race and have the MVMODEL plot the estimates as shown in the proc logistic forest plot but still be formatted as the MVMODEL forest plot?
If that makes sense.
I have an input dataset called infarct.
I ran proc logistic, modeling infarct as event='Yes' (for some reason SAS gave me an error when I modeled infarct for event=1 using the unformatted dataset), and it gives me a forest plot with the interaction terms between Sex and Race.
Data infarct ;
infile datalines delimiter="," ;
input BBlocker Alcohol Smoking Sex $ Race :$9. Age BMI TG Cpeptide Glucose Infarct @@;
datalines;
0,1,0,F,non-white,78,19.3,1.1,0.4,6.6,1
0,1,0,M,white,72,24.6,2.3,1.9,8.6,1
0,0,0,M,non-white,61,25.2,0.7,4.1,5.7,0
0,1,1,M,non-white,62,24.9,1,3.9,8.7,1
0,1,1,F,non-white,55,23.4,2.1,2.5,6.2,0
0,0,0,M,white,51,24.8,0.9,6.6,9.1,0
0,0,0,F,non-white,65,22.2,1.6,0.7,15.1,0
0,1,0,M,white,71,27.7,2.2,2.4,5.7,0
0,1,1,M,white,64,26.4,2.2,0.6,11.2,1
0,0,0,M,non-white,56,27.8,1.2,1.3,6.8,0
0,1,1,F,non-white,54,30.9,2.1,0.9,3.8,0
0,0,0,M,white,71,21.9,0.8,2.3,7.7,0
0,0,1,F,non-white,57,21.2,1.8,1.5,8.2,0
0,0,0,M,non-white,64,27.7,1.4,1.1,13.9,0
0,1,0,F,white,76,26.6,1.6,1.5,7.2,1
0,0,0,F,white,77,26.7,1.4,4.7,8.8,0
0,0,0,F,non-white,63,26.8,1.1,1.7,7.6,0
0,0,0,M,white,74,30.7,1.6,2.3,10.8,0
0,1,0,M,white,65,22.2,1.3,0.6,11.8,1
0,0,0,M,white,83,23.4,1.2,1.8,17.2,0
0,1,0,F,white,59,24.5,1.4,2.3,10.7,1
0,1,0,M,non-white,57,23.7,0.6,2.5,6.9,1
0,1,0,F,non-white,73,18.6,1.3,1.5,9.2,1
0,1,1,M,white,74,32.2,1.7,1.9,8.4,1
0,0,0,F,non-white,48,26.3,1.2,1.7,8.3,0
0,0,0,F,white,55,21.2,2.1,1.7,13.6,0
0,1,0,F,non-white,66,30.3,0.8,3.4,6,0
0,0,1,F,white,52,29.8,0.7,4.5,4,0
0,1,0,M,white,56,26.9,1.6,1,10.6,1
0,0,0,M,white,74,23.6,2,2.1,8.3,0
1,1,1,F,white,61,22.3,2.1,2.4,10.1,0
1,1,1,M,non-white,69,25.4,2.4,1.3,11.2,1
1,1,0,F,non-white,60,29.3,2.5,1.5,11.8,1
1,1,1,M,white,55,34.5,3.4,0.8,10.8,1
1,0,0,M,non-white,57,25.9,0.6,2.5,6.6,0
1,0,0,M,non-white,67,35,1.2,2.1,8.2,1
1,1,0,M,non-white,43,26.8,1.7,1.2,10.4,1
1,1,0,M,white,63,32.1,2.5,3.1,4.3,0
1,0,0,M,white,68,26.3,1.5,3.2,10.8,0
1,1,1,M,non-white,65,34.1,4.1,0.9,8.3,1
1,0,0,F,non-white,47,23.4,1.7,1.5,6.8,0
1,1,0,F,non-white,50,28.6,2.3,2.5,11.9,1
1,1,1,F,non-white,53,28.6,1.3,2.5,10.7,0
1,0,0,F,non-white,65,32.2,0.6,2.3,9.7,0
1,1,1,M,non-white,68,26.1,0.6,2.3,5.7,0
1,0,0,M,non-white,53,26.7,0.6,2.5,8.3,0
1,1,0,M,non-white,60,31.2,1.9,1.9,7.2,1
1,0,0,M,non-white,59,33.2,1.1,2.9,16.7,0
1,1,1,F,non-white,57,28.1,3.9,2.7,8.7,1
1,0,0,M,white,59,23.9,2.5,1.9,13.6,0
1,1,1,M,non-white,69,25.7,0.9,0.8,10.6,1
1,1,0,M,white,59,23.5,7.4,1.9,13.9,0
1,0,1,F,non-white,67,29.6,2.1,5.1,11.9,1
1,1,0,F,non-white,66,32.6,2.3,6.1,6,0
1,1,0,F,white,58,27.8,0.9,1.7,9.1,0
1,0,1,M,non-white,54,33.9,1.8,1.7,8.4,1
1,0,0,F,white,64,24.4,1.9,2.4,9.1,0
1,1,0,F,white,52,27.5,2.3,2.3,10.9,1
1,1,0,F,white,48,27.4,2.9,1.7,7.7,1
1,1,0,F,non-white,62,32.3,4.7,2.1,8.8,1
1,1,1,F,non-white,50,25.9,2.4,1.1,20.7,1
1,0,1,M,white,56,24,1.7,4.5,10.6,0
1,1,0,M,non-white,70,24.5,4.5,0.8,15.1,1
1,0,0,F,white,58,35.7,1.5,3.2,17,0
1,1,0,F,non-white,62,29.6,1.1,3.4,8.4,0
1,0,0,F,non-white,62,27.4,1,4.7,8.6,0
1,1,0,F,non-white,68,30.3,1.5,3.9,9.2,1
1,1,0,F,white,53,29.5,0.7,2.4,9.2,0
1,0,1,F,non-white,68,29.7,1.5,1.8,11.2,1
1,1,0,F,non-white,62,25.7,2.4,4.1,10.8,1
1,1,1,F,non-white,58,29.8,0.6,1.1,7.6,0
;
run;
proc format;
value Infarctfmt 0 = "No"
1 = "Yes"
;
value BBlockerfmt 0 = "No"
1 = "Yes"
;
value Alcoholfmt 0 = "No"
1 = "Yes"
;
value Smokingfmt 0 = "No"
1 = "Yes"
;
run;
data infarct;
set infarct;
format infarct Infarctfmt.;
format alcohol Alcoholfmt.;
format BBlocker BBlockerfmt.;
format smoking Smokingfmt.;
run;
proc logistic data=infarct plots(only)=(EFFECT ODDSRATIO(logbase=10 TYPE=HORIZONTALSTAT ));
class BBlocker(ref='No') Alcohol(ref='Yes') Smoking(ref='Yes') Sex(ref='M') Race(ref='non-white') /param=ref ;
model infarct(event='Yes')= BBlocker Alcohol Smoking Sex|Race Age BMI TG Cpeptide Glucose / orpvalue clodds=wald lackfit;
oddsratio BBlocker / cl=wald;
oddsratio Alcohol / cl=wald;
oddsratio Smoking / cl=wald;
oddsratio Sex / cl=wald;
oddsratio Race / cl=wald;
oddsratio Age / cl=wald;
oddsratio BMI / cl=wald;
oddsratio TG / cl=wald;
oddsratio Cpeptide / cl=wald;
oddsratio Glucose / cl=wald;
run;
quit;
Forest Plot from proc logistic
Code for MVMODEL (I've attached a modified version that adds the option for third reference line) does not allow me to enter interaction terms, but I like the way it's formatted and how the odds ratios and confidence intervals are limited to 2 decimal places:
%mvmodels (DATA=infarct, METHOD=LOGISTIC, NMODELS=1,
EVENTCOV=infarct,EVENT=Yes,COVARIATES=BBlocker Alcohol Smoking Sex Race Age BMI TG Cpeptide Glucose, TYPE=2 2 2 2 2 1 1 1 1 1 ,
CONT_DISPLAY=2, CAT_DISPLAY=4, cat_param=ref, cat_ref=No`Yes`Yes`M`non-white,
XAXISTYPE=log, LOGBASE=10, XAXISLABEL=Odds Ratios (log scale),
PVAL_TYPE3=0,
DISPLAY=subtitle or_plot or_est_range , show_adjcovariates=1, pval_covariates=1, refline=1, SREFLINE=0.5, SREFLINEPATTERN=SHORTDASH,
TREFLINE=1.5, TREFLINEPATTERN=SHORTDASH, LOGTICKSTYLE = LOGEXPAND, LOGMINOR=TRUE,
LINECOLOR=blue, labels=Beta Blocker``Smoking Status```Age in years`BMI (%)`Triglycerides (mmol/L)`C-Peptide (nmol/L)`HbA1c (%),REFGUIDELOWER=Lower Odds of MI, REFGUIDEUPPER=Higher Odds of MI);
Forest Plot from %MVMODELS macro
... View more