Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Programming
- /
- Graphics
- /
- Plotting of rstudent by regressors in SAS University Edition

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 01-14-2015 05:59 PM
(6552 views)

Hi all

I am learning SAS Studio (University edition) as we plan on using this to teach our Multiple regression course this year instead of SAS 9.3 or 4

I am trying to produce plot/s of rstudent v the regressors.

Here is an example of how I would have done this with my 'normal' SAS software.

PROC REG DATA=dataset ;

MODEL outcome = var1 var2 / R;

PLOT rstudent.*(var1 var2 predicted.);

RUN;

This would have produced three plots all with rstudent on y axis.

In SAS studio I can get the rstudent by predicted without issue as it is a standard component of the diagnostic plots (also I can code **Plots = rstudentbypredicted** if I wanted a bigger one).

The only plots I can get for Var1 and Var2 are for plain residuals and I can't seem to find any code for rstudent by regressor/s

Can anyone help please?

Regards

Marisa

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Use the OUTPUT statement to save the studentized residuals and predicted values to a data set. Use PROC SGPLOT to create the graphs:

PROC REG DATA=sashelp.class plots(only)=rstudentbypredicted ;

MODEL age = height weight / R;

output out=RegOut P=Predicted RSTUDENT=RStudent;

RUN;

proc sgplot data=RegOut;

scatter x=Height y=RStudent;

run;

proc sgplot data=RegOut;

scatter x=Weight y=RStudent;

run;

10 REPLIES 10

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

The PLOT statement does not appear in the SAS STAT 13.2 documentation, but it does in SAS STAT 13.1. In this case I'd create an output dataset and manually plot it. Not a great solution, but a quick work around. It's probably worth knowing how to store the output in a dataset anyways

Running on SAS University Edition I get the following error. I'd contact Tech Support directly regarding this.

39 PROC REG DATA=sashelp.class ;

40 MODEL weight = height age / R;

41 PLOT rstudent.*(height age predicted.);

42 RUN;

ERROR: Appendage SASXGANO not found, unable to produce graphics.

NOTE: The SAS System stopped processing this step because of errors.

NOTE: The PROCEDURE REG printed pages 3-4.

NOTE: PROCEDURE REG used (Total process time):

real time 4.15 seconds

cpu time 0.97 seconds

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Hi Sanjay

Please find below the code and the plot I require that I produced from SAS 9.4.

The GFR dataset is attached.

The plots that I am having problems with are **bolded**.

I successfully get the standard diagnostic plots and residuals by x variables but receive the following error message from SAS Studio V 3.1

ERROR: Appendage SASXGANO not found, unable to produce graphics.

I have seen discussions regarding this error message that say you should use the PLOTS = option which I have tried but there does not appear to be an option for rstudent by x variables just rstudentbypredicted or leverage.

DATA gfr;

INFILE 'c:\data\gfr.dat'; *Use INFILE '/folders/myfolders/gfr.dat'; for SAS studio;

INPUT id age cr gfr;

* Calculate inverse CR;

invcr = 1/cr;

RUN;

TITLE 'Relationship between GFR and creatinine';

PROC UNIVARIATE DATA = GFR PLOT;

VAR age cr gfr invcr;

RUN;

PROC REG CORR DATA = GFR ;

MODEL gfr=cr;

** PLOT rstudent.*(cr predicted.);**

MODEL gfr=invcr / R;

** PLOT rstudent.*(invcr predicted.);**

* save the residuals of the previous model in 'RESIDS';

OUTPUT OUT=resids RSTUDENT=jackknife;

RUN;

* Check the distribution of the residuals;

PROC UNIVARIATE DATA=resids NORMAL PLOT;

VAR jackknife;

QQPLOT / NORMAL (MU=est SIGMA=est);

RUN;

**This is the plot produced by PLOT rstudent. * cr**

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Not sure of the details. I sent it to others who know more about stat procedures.

Try adding a "ods graphics on;" statement before the call to the procedures.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Thanks Sanjay and Reeza

I have tried ODS graphics on and followed all instructions I could find on SAS site but still no good.

Reeza you mentioned workarounds which is fine but we are trying to teach introductory regression to students so we want it to be as standard as possible from one year to the next.

Marisa

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

I agree, not a fan of changes from version to version, but sometimes necessary.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Here is another suggestion from stat experts. Rick covered how to so some graphs using SGPLOT.

"She is using the old Plots statement which predates Ods graphics and produces grseg graphs. She should switch to using the Plots= option. There may be some combinations of plots you now can't get with the option and those would need to be done with SGPlot."

Another suggestion:

proc reg data=sashelp.class;

model age = height weight / r;

output out=b p=p rstudent=rs;

run; quit;

proc sgscatter; plot rs*(height weight p); run;

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Thank you all for your help; I have used both Rick's and Sanjay's code and have got what I need.

This plot didn't have a reference line at 0 which was a shame so added the following 'refline' code

proc sgplot;

scatter y = rstudent x = var1;

refline 0 / axis = y;

run;

Sorry for the delay in responding.

Marisa

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Use the OUTPUT statement to save the studentized residuals and predicted values to a data set. Use PROC SGPLOT to create the graphs:

PROC REG DATA=sashelp.class plots(only)=rstudentbypredicted ;

MODEL age = height weight / R;

output out=RegOut P=Predicted RSTUDENT=RStudent;

RUN;

proc sgplot data=RegOut;

scatter x=Height y=RStudent;

run;

proc sgplot data=RegOut;

scatter x=Weight y=RStudent;

run;

**SAS Innovate 2025** is scheduled for May 6-9 in Orlando, FL. Sign up to be **first to learn** about the agenda and registration!

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.

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