Table of Contents
A residual plot in SAS is a graphical representation of the differences between the observed values and the predicted values from a statistical model. To create a residual plot in SAS, first, a statistical model must be created using either the PROC REG or PROC GLM procedure. Once the model is created, the residuals can be obtained using the OUTPUT statement. The residuals can then be plotted against the independent variable to check for patterns or trends. This can be done using the PLOT statement in PROC SGPLOT or PROC GPLOT. The resulting plot can help in identifying any potential issues with the model, such as heteroscedasticity or non-linearity, and guide in making necessary adjustments.
Create a Residual Plot in SAS
Residual plots are often used to assess whether or not the in a regression model are normally distributed and whether or not they exhibit .
You can use the following basic syntax to fit a regression model and produce a residual plot for the model in SAS:
symbol value = circle; proc reg data=my_data; model y = x; plot residual. * predicted.; run;
The following example shows how to use this syntax in practice.
Note: The symbol statement specifies that we would like to display the points in the residual plot as circles. The default shape is a plus sign.
Example: Create Residual Plot in SAS
Suppose we have the following dataset in SAS:
/*create dataset*/
data my_data;
input x y;
datalines;
8 41
12 42
12 39
13 37
14 35
16 39
17 45
22 46
24 39
26 49
29 55
30 57
;
run;
/*view dataset*/
proc printdata=my_data;

We can use the following syntax to fit a to this dataset and create a residual plot to visualize the residuals vs. predicted values:
/*fit simple linear regression model and create residual plot*/
symbolvalue = circle;
proc regdata=my_data;
model y = x;
plot residual. * predicted.;
run;
The residual plot will be displayed at the bottom of the output:

The x-axis displays the predicted values and the y-axis displays the residuals.
Since the residuals are randomly scattered about the value zero with no clear pattern of increasing or decreasing variance, the assumption of is met.
Along the top of the plot we can also see the fitted regression equation:
And along the right side of the plot we can also see the following metrics for the regression model:
- N: Total number of observations (12)
- Rsq: R-squared of the model (0.6324)
- AdjRsq: Adjusted R-squared of the model (0.5956)
- RMSE: The root mean squared error of the model (4.4417)
The following tutorials explain how to perform other common tasks in SAS:
Cite this article
stats writer (2024). How can I create a residual plot in SAS?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-can-i-create-a-residual-plot-in-sas/
stats writer. "How can I create a residual plot in SAS?." PSYCHOLOGICAL SCALES, 26 Jun. 2024, https://scales.arabpsychology.com/stats/how-can-i-create-a-residual-plot-in-sas/.
stats writer. "How can I create a residual plot in SAS?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-can-i-create-a-residual-plot-in-sas/.
stats writer (2024) 'How can I create a residual plot in SAS?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-can-i-create-a-residual-plot-in-sas/.
[1] stats writer, "How can I create a residual plot in SAS?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, June, 2024.
stats writer. How can I create a residual plot in SAS?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.
