******************************
* Program: birds.sas :
* Author: Joshua M. Tebbs :
* Date: 13 August 2005 :
* Example 2.6 (notes) :
******************************
 
PROC GPLOT is a "fancier" plot than that using PROC PLOT.
 
PROC CORR provides the correlation between two variables.
 
PROC REG has many useful options and features. For now, I'm just showing
the basics. The MODEL statement lists the response variable, then an
"=", then the explanatory variable (or variables in multiple regression,
which we will cover next semester).
 
The PLOT statement asks for certain useful plots to be made. In this
case, I am asking for a plot of residuals vs. predicted values ("r.*p.")
*/ ;
 
options ps=60 ls=80 pageno=1 formdlim='_' nodate;
 
/* Create a dataset, input the variables, and then the data */
data oxygen;
input temp rate;
cards;
-18 5.2
-15 4.7
-10 4.5
-5 3.6
0 3.4
5 3.1
10 2.7
19 1.8
;
 
proc print;
title 'OXYGEN CONSUMPTION DATA';
run;
 
/* Create a scatterplot of the data */
proc gplot;
plot rate*temp;
run;
 
/* Compute the correlation */
proc corr;
var temp rate;
run;
 
/* Compute the least squares regression equation */
proc reg;
model rate = temp;
run;
 
/* Basic residual plot
"p" = predicted values for each observation (y-hat)
"r" = residuals for each observation (e)
*/
proc reg;
model rate = temp/p r;
plot r.*p.;
run;