BookmarkSubscribeRSS Feed
stodo53
Calcite | Level 5

Hi everyone,

 

I was wondering if anyone knows whether you can graphically display a regression line that also shows a categorical*continuous interaction using proc surveyreg

exposure=categorical

outcome=continuous

interaction= categorical*continuous

covariates used = continuous + categorical

 

This is basically how I would like it to look:

the x-axis has the continuous variable from the interaction term displayed
the y-axis has the continuous outcome displayed

Then, there would be 4 different lines to represent the categorical variable (it has 4 levels) 

 

If anyone has a helpful link or a code that I could follow, that would be great!

 

Thanks in advance,

 

Sara

10 REPLIES 10
Zard
SAS Employee

Hi Sara.

 

PROC SURVEYREG doesn't produce this kind of plot, but you could use the STORE statement and PROC PLM. For example, 

 

proc surveyreg data=sashelp.class;
class sex;
model weight=sex|height;
store sreg;
run;
proc plm restore=sreg;
effectplot slicefit(sliceby=sex);
run;

stodo53
Calcite | Level 5

Hi Zard,

 

Thanks so much for your reply. That did work. Just one more follow-up question if you don't mind; is there anyway to do this (e.g., use PLM to plot the interaction) with a multiply imputed dataset? I used multiple imputation with the survey procedures to model my regression. 

 

Thanks in advance!

 

Sara

Zard
SAS Employee

Hi Sara.

 

I'm not aware of a way to do this, since PROC MIANALYZE does not have a STORE statement.

SteveDenham
Jade | Level 19

Well,  you can use ODS OUTPUT to get various datasets from MIANALYZE.  I would think the parameterestimates dataset would work.  You might have to merge it back against the original data, but then you could use SGPLOT to get what you want (I think).  Check out the last example in the PROC MIANALYZE documentation to see if that looks like it might be useful.

 

SteveDenham

Saifulinfs
Fluorite | Level 6
Could you kindly share any example code for using the parameterestimates dataset from proc mianalyze to plot an interaction?
Rick_SAS
SAS Super FREQ

> is there anyway to do this (e.g., use PLM to plot the interaction) with a multiply imputed dataset? I used multiple imputation with the survey procedures to model my regression. 

 

Do you want the final model (averaged over all imputations), or do you want a plot for each set of imputed values? If you want B plots, one for each imputed value, you can use a BY statement in the survey procedures, then use the PLOTBY= option on the EFFECTPLOT statement. For examples, see the article "Use the EFFECTPLOT statement to visualize regression models in SAS."

 

If you want the averaged model, use the final parameter estimates to build the predictive model in the DATA step.

Saifulinfs
Fluorite | Level 6
Hello

Could you kindly share any example code for using the parameterestimates dataset from proc mianalyze to plot an interaction?
Rick_SAS
SAS Super FREQ

Follow the ideas in the article "How to create a sliced fit plot in SAS."

The MIANALYZE procedure creates a ParameterEstimates table. Use those estimates to score the model for a range of values for the continuous variable and for each level of the categorical variable. Then use a SERIES stmt in PROC SGPLOT with the GROUP= option to display the lines for each level of the categorical variable.

Saifulinfs
Fluorite | Level 6
Thank you for your reply. Actually I am a new SAS user. Any help on using ParameterEstimates table from Proc MIanalyze to score a model for a range of values? Many thanks
Rick_SAS
SAS Super FREQ

Everybody was new once. Read the article and the links and you will begin to learn.

 

Two tips about getting help:

1. Creating a new thread is better than jumping on an old thread started by someone else years ago.

2. Short questions tend to get short answers. If yu want a longer response, ask a detailed question that includes sample data, sample program, and example output.

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 10 replies
  • 1671 views
  • 3 likes
  • 5 in conversation