Hey Folks,
I am running a SAS Proc Reg procedure and producing prediction plots using the Plots syntax. I have a control and 3 treatment levels that I would like to overlay each regression and their respective CLM CLI. I can get the plots separately fine but when I use overlay it builds CLM CLI around all the regression lines not each individually. How can I correct this? Pgm below, plots attached.
proc sort data=MeanTotTRlat; by treatment;
proc reg data=MeanTotTRlat plots=predictions (x=LatR );
var LatR2;
model TotTR = LatR LatR2;by treatment;
plot overlay;
run;quit;
I apologize for not answering that portion of your question.
First, a confession: I simplified the call by using PLOTS=FITPLOT, which is sort of a generic specification. The actual name of the plot you are creating is the ANCOVAPLOT, as stated in the documentation for the PLOTS= option
To get only CLM, use PLOTS=ANCOVAPLOT(CLM)
To get only CLI, use PLOTS=ANCOVAPLOT(CLI)
Because you want both, you can use
proc glm data=MeanTotTRlat plots=ancovaplot(limits);
Be aware that the four lines with confidence bands might overlap and the graph might look crowded.
A few thoughts:
1. SAS introduced ODS statistical graphics way back in version 8, so you should upgrade to ODS. The newer graphs have many advantages over the older graphs.
2. There is a difference between BY-group analysis by treatment and using treatment as a CLASS variable. If you put Treatment on a CLASS statement, the overlay will happen automatically. As a bonus, you can compare the treatment effects in the statistical output.
3. You can switch from PROC REG to PROC GLM to solve two problems: (A) PROC GLM enables you to use the quadratic variable LatR*LatR directly without having to create it in a DATA step, and (B) PROC GLM supports the CLASS statement.
Putting these all together, the following statements provide what you want
ods graphics on;
proc glm data=MeanTotTRlat plots=FitPlot;
class treatment;
model TotTR = latR LatR*LatR treatment;
run;
I apologize for not answering that portion of your question.
First, a confession: I simplified the call by using PLOTS=FITPLOT, which is sort of a generic specification. The actual name of the plot you are creating is the ANCOVAPLOT, as stated in the documentation for the PLOTS= option
To get only CLM, use PLOTS=ANCOVAPLOT(CLM)
To get only CLI, use PLOTS=ANCOVAPLOT(CLI)
Because you want both, you can use
proc glm data=MeanTotTRlat plots=ancovaplot(limits);
Be aware that the four lines with confidence bands might overlap and the graph might look crowded.
Perfect, thanks!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.