Hi,
We are trying to test for normality on residuals of the dv when the iv is categorical. Proc reg does not run when iv is categorical.
Here is the code:
proc reg data=sample1;
model dv= iv;
output out = notrans r= resid;
run;
proc univariate data=notrans noprint;
var resid;
histogram resid/normal kernel;
qqplot resid/normal (mu = est sigma=est);
run;
This glm proc runs because the categorical variable iv is numeric. But it is treated as interval, and NOT categorical because it is not mentioned in a CLASS statement. In other words, you are running a regression instead of an ANOVA.
Add the statement
CLASS iv;
to your glm code to get an ANOVA.
PROC REG doesn't work with categorical variables but PROC GLM does.
@ANKH1 wrote:
Hi,
We are trying to test for normality on residuals of the dv when the iv is categorical. Proc reg does not run when iv is categorical.
Here is the code:
proc reg data=sample1;
model dv= iv;
output out = notrans r= resid;
run;
proc univariate data=notrans noprint;
var resid;
histogram resid/normal kernel;
qqplot resid/normal (mu = est sigma=est);
run;
"Does not run" is awful vague.
Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.
No output? Post any log in a code box.
Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.
If your IV variable is character then Proc Reg won't run as it is only for numeric values.
This glm proc runs because the categorical variable iv is numeric. But it is treated as interval, and NOT categorical because it is not mentioned in a CLASS statement. In other words, you are running a regression instead of an ANOVA.
Add the statement
CLASS iv;
to your glm code to get an ANOVA.
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 25. 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.