SAS Scatterplots

First came LINEPRINTER plots.
Then PROC GPLOT (1988 or so). Must define symbols and line types. Quite cludgy, output is not pleasing.
goptions reset=all border;

title "Study of Height vs Weight";
footnote1 j=l "Source: T. Lewis & L. R. Taylor";
footnote2 j=l "Introduction to Experimental Ecology"
          j=r "GPLVRBL1(a) ";

proc gplot data=sashelp.class;
   plot height*weight;
run;
footnote1; /* this clears footnote1 */
symbol1 interpol=rcclm95
       value=circle
       cv=darkred
       ci=black
       co=blue
       width=2;
plot height*weight / haxis=45 to 155 by 10
                        vaxis=48 to 78 by 6
                        hminor=1
                        regeqn;
run;

Now do a simple regression and plot in R.
kids <- read.table("http://www.math.montana.edu/~jimrc/classes/stat408/data/kidsHtWt.txt", head=T)
write.table(kids,file="kidsHtWt.txt",sep="\t", row.names=F)
pairs(kids)
fit1 <- lm( wt ~ ht + age, kids)
par(mfrow=c(2,2))   ## set up for 4 plots per page in 2 rows, 2 columns
plot(fit1)
Plots are used as diagnostics:
  1. residuals versus fitted values. What do we look for?
  2. sorted residuals versus normal quantiles. straight line means what?
  3. spread-location plot. Look for a half-fan shape and an overall trend to indicate nonconstant variance.
  4. leverage plot. Points outside dashed red lines are influential.

Now we have ODS graphics and SGPLOT in SAS:
DATA kids;
  infile "kidsHtWt.txt" firstobs=2;
  input  sex $ age :3.1 height weight;

ods graphics on;

PROC REG;
   model  weight = height age;
run;

Plots: First column -- like top row in R.
Rstudent means studentized residuals. They are adjusted so they all should have equal variance.

Panel 1 also shows residuals versus predictors.


SGPLOT
proc sgplot data= sashelp.class;
  scatter x=height y=weight / group=sex;
run;

proc sgplot ;
  reg x=height y=weight / CLM CLI;
run;

proc sgplot data=sashelp.class(where=(age<16));
  dot age / response=height stat=mean
            limitstat=stddev numstd=1;
run;



Author: Jim Robison-Cox
Last Updated: