turn on suggestions

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

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS/GRAPH and ODS Graphics
- /
- Plotting of rstudent by regressors in SAS Universi...

Topic Options

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

01-14-2015 05:59 PM

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

Accepted Solutions

Solution

01-15-2015
07:13 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to marisa_jenkins

01-15-2015 07:13 AM

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;

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to marisa_jenkins

01-14-2015 06:50 PM

Can you attach a fully working program with data? Or, a program that uses one of the data sets from SASHELP to illustrate the issue. Also include SAS Studio release (R3.2, R3.2, etc.). You may get better help posting to the "SAS Statistical Procedures" communities page.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Sanjay_SAS

01-14-2015 07:50 PM

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
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Sanjay_SAS

01-14-2015 08:11 PM

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
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to marisa_jenkins

01-14-2015 08:29 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

01-14-2015 08:33 PM

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
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Sanjay_SAS

01-14-2015 09:16 PM

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
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to marisa_jenkins

01-14-2015 10:58 PM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to marisa_jenkins

01-15-2015 09:36 AM

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
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Sanjay_SAS

01-28-2015 08:26 PM

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

Solution

01-15-2015
07:13 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to marisa_jenkins

01-15-2015 07:13 AM

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;