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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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