Hello, I am looking at significant interaction and want to produce error bars in SAS. I am using PROC LOGISTIC and I used the LRT test to determine significant interactions. I will include a sample diagram of what the graphs should look like.
proc logistic data=multi descending;
class damage(ref=first) smell(ref=first) smokeinlive(ref=first) employ(ref=first) pain(ref=first) clinicalinsomnia(ref=first) sleepquality1(ref=first) everasthma(ref=first) evercb(ref=first) evercopd(ref=first) depression(ref=first) everptsd(ref=first)/param=reference;
model everanxiety=damage smell smokeinlive employ clinicalinsomnia sleepquality1 pain everasthma evercb evercopd depression everptsd employ*sleepquality1 smokeinlive*sleepquality1;
run;
One way to do this is to use the EFFECTPLOT statement and ask for an interaction plot. Notice that since you have more than two explanatory variables, you must specify values for the variables that do not appear in the plot. There are several ways to do this, but PROC PLM will choose the reference values by default, which is probably what you want.
Since I don't have your data, here is an example that shows how to get the plot for some data in the Sashelp.cars data set:
data cars;
set sashelp.cars;
Y = (origin='Asia'); /* make binary response var */
if type not in ('Hybrid','Truck') AND cylinders in (4,6);
run;
proc logistic data=cars descending;
class Type(ref=first) Cylinders(ref=first) DriveTrain(ref=first) / param=reference;
model Y = Type Cylinders DriveTrain Type*Cylinders;
store logiModel;
run;
/* plot interactions. See
https://blogs.sas.com/content/iml/2019/05/30/visualize-interaction-effects-regression.html
*/
proc plm restore=logiModel noinfo;
effectplot interaction(x=Type sliceby=DriveTrain) / cluster clm connect;
run;
If you don't want the default choices for the other explanatory variables, you can use the AT= option to override the default:
proc plm restore=logiModel noinfo;
effectplot interaction(x=Type sliceby=DriveTrain) / at(Cylinders='6') cluster clm connect;
run;
For more information about the EFFECTPLOT and PROC PLM, see
One way to do this is to use the EFFECTPLOT statement and ask for an interaction plot. Notice that since you have more than two explanatory variables, you must specify values for the variables that do not appear in the plot. There are several ways to do this, but PROC PLM will choose the reference values by default, which is probably what you want.
Since I don't have your data, here is an example that shows how to get the plot for some data in the Sashelp.cars data set:
data cars;
set sashelp.cars;
Y = (origin='Asia'); /* make binary response var */
if type not in ('Hybrid','Truck') AND cylinders in (4,6);
run;
proc logistic data=cars descending;
class Type(ref=first) Cylinders(ref=first) DriveTrain(ref=first) / param=reference;
model Y = Type Cylinders DriveTrain Type*Cylinders;
store logiModel;
run;
/* plot interactions. See
https://blogs.sas.com/content/iml/2019/05/30/visualize-interaction-effects-regression.html
*/
proc plm restore=logiModel noinfo;
effectplot interaction(x=Type sliceby=DriveTrain) / cluster clm connect;
run;
If you don't want the default choices for the other explanatory variables, you can use the AT= option to override the default:
proc plm restore=logiModel noinfo;
effectplot interaction(x=Type sliceby=DriveTrain) / at(Cylinders='6') cluster clm connect;
run;
For more information about the EFFECTPLOT and PROC PLM, see
Sorry for the late response, I was able to figure it out before anyone saw the post. But thank you so much!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.