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

I have known of interaction for a long time. But I do not know how to code the  simple effects or graph them . I have not worked with estimate statements before.  The problem I have is I do not have the original categorical variable only the dummies derived from It. There were 5 levels in the original variable, I have four dummies in my data set. I assume I can just generate the interaction between my interval variable and the dummy variables (so there will be four interaction terms). But am not sure how I go from the following to that  or even if you can. The analysis I have seen focuses on the original categorical variable not its levels (the dummies built from it) which is part of my confusion. If there is aa simpler way to do this I will, it is the best code I have found.

 

Note that before this step was a proc glm imported into proc plm.I found code how to generate results for an interaction of a categorical variable and an interval (hours) variable (the categorical variable prog has three levels the third is the reference level).

 

To plot the simple effects

proc plm restore = catcont;

estimate 'hours slope, prog=1 jogging' hours 1 hours*prog 1 0 0,

'hours slope, prog=2 swimming' hours 1 hours*prog 0 1 0,

'hours slope, prog=3 reading' hours 1 hours*prog 0 0 1 / e;

 

A similar problem this will plot the data, but I am not sure how to do it with the  dummies.

  • proc plm resore=catcont;

  • effectplot slicefit (x=hours sliceby=prog) / clm;

 run;

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
StatDave
SAS Super FREQ

Do not use the ESTIMATE statement. Instead use the SLICE statement to estimate and graph the effects in the interaction. There are plenty of examples at support.sas.com such as in this note and this note. To do that, you need to reconstruct the original categorical variables from the dummy variables you have. That is easily done in a DATA step. For example, if you have 3 dummy variables (A, B, and C) for a 4-level categorical variable, then something like the following will produce a single categorical variable (GRP) that you can use in the CLASS, MODEL, and SLICE statements..

data new;
set old
if a=1 then grp='A';
else if b=1 then grp='B';
else if c=1 then grp='C';
else grp='D';
run;

View solution in original post

3 REPLIES 3
gcjfernandez
SAS Employee

If you are looking for a simple solution to estimate the intercept and the slope :

 

proc glm data=sashelp.class;
class sex;
model weight= sex height(sex)/ss3 noint solution;
run;

You will get the intercepts and slopes directly:

gcjfernandez_gmail_com_0-1629011698154.png

 

StatDave
SAS Super FREQ

Do not use the ESTIMATE statement. Instead use the SLICE statement to estimate and graph the effects in the interaction. There are plenty of examples at support.sas.com such as in this note and this note. To do that, you need to reconstruct the original categorical variables from the dummy variables you have. That is easily done in a DATA step. For example, if you have 3 dummy variables (A, B, and C) for a 4-level categorical variable, then something like the following will produce a single categorical variable (GRP) that you can use in the CLASS, MODEL, and SLICE statements..

data new;
set old
if a=1 then grp='A';
else if b=1 then grp='B';
else if c=1 then grp='C';
else grp='D';
run;
noetsi
Obsidian | Level 7
Thanks for the advice of reconstituting. That is what I guessed. I am going to do this with a case statement in Proc SQL rather than a data statement because I work with sql a lot and rarely data statements.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 3 replies
  • 1030 views
  • 1 like
  • 3 in conversation