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

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?

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

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;

 

View solution in original post

4 REPLIES 4
Lacona
Quartz | Level 8

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.

FreelanceReinh
Jade | Level 19

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;

 

Lacona
Quartz | Level 8

Thank you so, so much!
It worked perfectly fine!

SAS Innovate 2025: Register Now

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!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 994 views
  • 1 like
  • 3 in conversation