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;
Works for me. Show us (a portion of) the output data set named RESID so we can see what you are seeing.
Works for me. Show us (a portion of) the output data set named RESID so we can see what you are seeing.
@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.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.