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
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;
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:
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;
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!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.