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

I am running a regression model with a BY statement, where individual regression models are run for each group.  I want the residual values which are stored in the output dataset to be for the regression model of the applicable group for each observation.  I thought that just by placing the BY statement before the output statement would do this, but after looking at the residual values that doesn't appear to be the case.  Is there a way to do this within the PROC REG procedure or will separate output groups have to be concatenated?  If the latter is the case, how do I get an output table for each model?  Here is how I wrote my code:

 

proc reg data=MY_DATA ;
model  Y_VAR = X_VAR/r ;
by GRP_NAME;
output out=resid
r=yresid 
cookd=cooks;
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Works for me. Show us (a portion of) the output data set named RESID so we can see what you are seeing.

--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

Works for me. Show us (a portion of) the output data set named RESID so we can see what you are seeing.

--
Paige Miller
RandoDando
Pyrite | Level 9

@PaigeMiller  After I sent this question, I ran PROC REG on 1 group, then output that as RESID1.  I then merged that with the applicable subset of RESID by ID and compared the residual values.  They matched.  

A couple of the groups have higher than expected residuals for some cases, and that is what threw me off at first.  

Reeza
Super User
REG needs a QUIT at the end because it can be interactive.

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
  • 444 views
  • 0 likes
  • 3 in conversation