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

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;

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

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.

PG

View solution in original post

8 REPLIES 8
Reeza
Super User
What's your hypothesis? It seems weird to do regression with a single categorical variable, that seems more designed for an ANOVA instead.
ANKH1
Pyrite | Level 9
Yes, it is Anova
PaigeMiller
Diamond | Level 26

PROC REG doesn't work with categorical variables but PROC GLM does.

--
Paige Miller
ballardw
Super User

@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.

Reeza
Super User
If you're trying to verify the assumptions, you would need to ensure the distributions are similar for the ANOVA, it's pretty robust to non-normal distributions as long as the distributions are similar and the standard deviations are similar.
PGStats
Opal | Level 21

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.

PG
ANKH1
Pyrite | Level 9
It worked! Thank you very much.

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