Hi! I'm an experienced beginner with SAS and am running a logistic regression. I used the effectplot statement with proc logistic to visualize an interaction between 2 categorical variables, and I'd like to capture the underlying data for that effect plot. I read through the User Guide on Proc Logistic and I checked the list of ODS Table Names and didn't see anything related to this. I'm using the latest version of SAS University and would appreciate any help. Thanks!
ods output slicefitpanel = want;
Use ODS TRACE method to find the table name in these cases.
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...
@panchang wrote:
Hi! I'm an experienced beginner with SAS and am running a logistic regression. I used the effectplot statement with proc logistic to visualize an interaction between 2 categorical variables, and I'd like to capture the underlying data for that effect plot. I read through the User Guide on Proc Logistic and I checked the list of ODS Table Names and didn't see anything related to this. I'm using the latest version of SAS University and would appreciate any help. Thanks!
Thanks for the quick response! I used ODS trace and the ODS table name turned out to be Interaction Plot, not Slice Fit Panel. Here is the code I used to get the run the regression, and export the output data for the effect plot:
ods output InteractionPlot = output ;
proc logistic data = models.full2;
class city2 hhsize2 housemod2 ctbsafe2 floor2 watfreq_pre
/ param = ref ;
model avoid_pre = city2 age_pre possess hhsize2 housemod2 ctbsafe2
floor2 yearsinslum3 watfreq_pre
ctbsafe2*watfreq_pre /* / expb */ ;
/* oddsratio ctbsafe2 / at(watfreq_pre = all) diff = ref ; */
effectplot interaction (x = watfreq_pre sliceby = ctbsafe2) ;
/* output out = out_avoid predicted = preds; */
run;
proc export data = output
dbms = xlsx
outfile= "/folders/myfolders/sasuser.v94/impact/analysis/output-av.xlsx"
replace;
run;
However, I'm having a hard time understanding the output. The first 5 lines are blank (even though there are no missing values), and the column names are unclear to me. I've pasted the first several lines below, including column names. Is there a help page somewhere to figure out what these are? Thank you!
_PREDICTED | _XCLAS | _GROUP | _INDEX | _XCLAS_OBS | _PREDICTED_OBS | _Y_OBS | _OBSNUM | _YVAR_OBS_VALUE |
0 | 1 | 0 | ||||||
0 | 1 | 1 | ||||||
1 | 2 | 0 | ||||||
1 | 2 | 1 | ||||||
1 | 2 | 1 | 0.11893273 | 0 | 1 | 1 | ||
1 | 2 | 1 | 0.220645038 | 0 | 2 | 1 | ||
1 | 2 | 1 | 0.074104704 | 0 | 3 | 1 | ||
1 | 2 | 1 | 0.063730638 | 0 | 4 | 1 |
I see. Basically, the interaction plot produced by the code is attached - I want to re-orient it to a bar graph or something else that might be easier to visualize. My idea was to make 4 bars, with different combinations for ctbsafe= 0, 1, and watfreq_pre = 0, 1. So I thought if I just downloaded the data into Excel or something that might be easier, but since the output data looks so confusing, I'm not sure how to proceed. It seems like my options are 1) use ODS graphics to manipulate the interaction plot (but I read that ODS graphics is not available with SAS University), or 2) Use PROC TEMPLATE to figure out what the graph dataset is giving me. Does that sound right?
@panchang wrote:
I see. Basically, the interaction plot produced by the code is attached - I want to re-orient it to a bar graph or something else that might be easier to visualize. My idea was to make 4 bars, with different combinations for ctbsafe= 0, 1, and watfreq_pre = 0, 1. So I thought if I just downloaded the data into Excel or something that might be easier, but since the output data looks so confusing, I'm not sure how to proceed. It seems like my options are 1) use ODS graphics to manipulate the interaction plot (but I read that ODS graphics is not available with SAS University), or 2) Use PROC TEMPLATE to figure out what the graph dataset is giving me. Does that sound right?
My opinion is that an interaction plot is not better when re-displayed as bars. I think that would be a mistake and make the interaction harder to visualize and interpret. Right now, you can see the two lines on the plot are not parallel, that is an interaction. I have no idea what an interaction looks like if you turn them into bars.
It would take too long to explain, but seeing how the predicted probabilities change with different combinations of the two binary variables I am interacting would actually assist in interpreting the trends from this regression. Other outside readers have suggested this as well. Thanks for your help.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.