Hey all,
I'm in desperate need for help, because I can't figure out how to make SAS giving me
residual, leverage, studentized residual, externally studentized residual, PRESS residual, Cook’s distance for one certain observation.
I was able to get residual, student.residual and Cook's distance by
proc reg data=filename;
model y= all the x/r;
run;
But there is no way I can get leverage, externally stud. residual and PRESS residual for my 10th observation.
Could you please help me out of my misery?
Hello @Lacona,
Add the INFLUENCE option to the MODEL statement.
Example:
proc reg data=sashelp.class;
model weight=height age / r influence;
quit;
This will add new columns to the output table "Output Statistics", including
The PRESS residual can be easily calculated from the residual (column "Residual" in the same table) and the leverage: divide the residual by (1 minus leverage). See documentation: Model Fit and Diagnostic Statistics. To avoid rounding errors in this calculation, I would use the ODS output dataset:
ods output OutputStatistics=stats;
proc reg data=sashelp.class;
model weight=height age / r influence;
quit;
data press;
set stats;
press_resid=divide(residual,1-hatdiagonal);
run;
Alternatively, you can obtain these three statistics from the OUTPUT dataset -- as suggested by @ChrisNZ:
proc reg data=sashelp.class;
model weight=height age / r influence;
output out=regstats rstudent=ext_stud_resid press=press_resid h=leverage;
quit;
proc print data=regstats;
run;
Have you looked at the output statement? More specifically at options press= and h= ?
See https://stats.idre.ucla.edu/sas/library/sas-libraryoverview-of-sas-proc-reg/
Yes, I did.
But I can't find a way to program it, so that it would show me the results for one specific observation.
Hello @Lacona,
Add the INFLUENCE option to the MODEL statement.
Example:
proc reg data=sashelp.class;
model weight=height age / r influence;
quit;
This will add new columns to the output table "Output Statistics", including
The PRESS residual can be easily calculated from the residual (column "Residual" in the same table) and the leverage: divide the residual by (1 minus leverage). See documentation: Model Fit and Diagnostic Statistics. To avoid rounding errors in this calculation, I would use the ODS output dataset:
ods output OutputStatistics=stats;
proc reg data=sashelp.class;
model weight=height age / r influence;
quit;
data press;
set stats;
press_resid=divide(residual,1-hatdiagonal);
run;
Alternatively, you can obtain these three statistics from the OUTPUT dataset -- as suggested by @ChrisNZ:
proc reg data=sashelp.class;
model weight=height age / r influence;
output out=regstats rstudent=ext_stud_resid press=press_resid h=leverage;
quit;
proc print data=regstats;
run;
Thank you so, so much!
It worked perfectly fine!
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.