/* This is an example of the REG procedure in SAS */ /* SAS code for least squares estimation of */ /* a simple linear regression model */ /* Consider the example on pg. 15 of the book */ /* I am calling the data set "task". */ /* The predictor variable is age. */ /* The response variable is attempts. */ data task; input age attempts; cards; 20 5 55 12 30 10 ; run; PROC REG DATA = task; MODEL attempts = age; OUTPUT OUT=NEW P=PRED; /* creates an output data set for plot below */ run; /* The following code includes a plot of the data and the fitted regression line: */ /* Note this uses the data set NEW and the variable PRED created above. */ symbol1 v=circle l=32 c = black; symbol2 i = join v=star l=32 c = black; PROC GPLOT DATA=NEW; PLOT attempts*age PRED*age/ OVERLAY; RUN; /* Note from the output, the fitted regression equation is: */ /* Y-hat = 2.8077 + 0.1769X */ /* Note MSE = 5.6538, and sqrt(MSE) = 2.378. */ /* (Can you find these in the SAS output?) */