Dear Community,
I would like to rename the axes for the plots received after using PROC GLM for a 2 way ANONA equation. I have managed to change the title for the plots and Y-axis. but I do not know how to proceed with x-axis labeling. These are the lines for my program:
option validvarname=any;
PROC GLM Data= work.BN (rename=NDF='NDF(dm), (%)'n) plots=(diagnostics);
CLASS Treatment ;
Model 'NDF(dm), (%)'n = Time |Treatment/solution;
Lsmeans Treatment /cl pdiff adjust=Tukey lines Stderr;
run;
quit;
Thank you and greatly appreciate your time and help.
Hi @VT89 ,
Actually please use this SGPLOT code. It has the legend title too.
proc sgplot data = ANCOVAPlot;
scatter x = _X7 y = _YVAR / group = _GROUP_OBS;
series x = _XCONT1 y = _Predicted_FIT / group = _GROUP_FIT name="series_leg";
keylegend "series_leg" / title = "Treatment" across=2 exclude=("") border;
yaxis label = "NDF(dm), (%)";
xaxis label = "X axis";
run;
Hello @VT89 ,
One way you can do it is to go edit the template that is creating the plot. Is it the diagnostics plot that you would like to change? If you update your dataset and the plot that you would like to change then it could be easier to assist you.
An example of editing the template behind the plot is first using ods trace on, to locate the template, and the obtain the code for the template, such as by using -
proc template;
source Stat.GLM.Graphics.FitSummary;
run;
After that you can modify the template.
It's probably easier just to output your dataset from Proc GLM though, and then use SGPLOT to create the plot and customize the axis.
Thanks,
Kriss
Hello,
Thank you so much for replying to my query. I am pasting the data I used for creating the plots. I was able to change the title for fit diagnostics plots but I could not find an easy way to edit ANCOVA plot x axis. I do not really know how to use proc template and I did give it a try before posting my question. I was thinking about using proc sgplot but I do not know how I can plot ANCOVA plot using sgplot. If I know how to then it would be easy to edit the axis and more.
Here is the data used for my equation.
SampleType | Treatment | Time | PlantPortion | ndfpw |
BN | S_I | 0 | F | 3.326147 |
BN | S_I | 0 | F | 4.085303 |
BN | S_I | 0 | F | 7.798459 |
BN | S_I | 0 | F | 1.854164 |
BN | S_I | 0 | F | 8.403201 |
BN | S_I | 0 | F | NA |
BN | S_I | 3 | F | 4.378336 |
BN | S_I | 3 | F | 5.970024 |
BN | S_I | 3 | F | 4.991754 |
BN | S_I | 6 | F | 6.077845 |
BN | S_I | 6 | F | 5.119463 |
BN | S_I | 6 | F | 7.625552 |
BN | S_I | 9 | F | 4.898555 |
BN | S_I | 9 | F | 5.667297 |
BN | S_I | 9 | F | 5.862422 |
BN | S_I | 12 | F | 8.046645 |
BN | S_I | 12 | F | 8.79686 |
BN | S_I | 12 | F | 8.624618 |
BN | S_NI | 0 | F | 1.854164 |
BN | S_NI | 0 | F | 8.403201 |
BN | S_NI | 0 | F | NA |
BN | S_NI | 0 | F | 3.326147 |
BN | S_NI | 0 | F | 4.085303 |
BN | S_NI | 0 | F | 7.798459 |
BN | S_NI | 3 | F | 7.225144 |
BN | S_NI | 3 | F | 6.853081 |
BN | S_NI | 3 | F | 6.329218 |
BN | S_NI | 3 | F | 8.708655 |
BN | S_NI | 6 | F | 4.530356 |
BN | S_NI | 6 | F | 6.884661 |
BN | S_NI | 6 | F | 9.946883 |
BN | S_NI | 6 | F | 8.250516 |
BN | S_NI | 9 | F | 6.647393 |
BN | S_NI | 9 | F | 6.343426 |
BN | S_NI | 9 | F | 5.817403 |
BN | S_NI | 9 | F | 5.767742 |
BN | S_NI | 12 | F | 7.546846 |
BN | S_NI | 12 | F | 6.657135 |
BN | S_NI | 12 | F | 6.755493 |
BN | S_NI | 12 | F | 3.543603 |
I really appreciate any help you can provide. Thank you again.
Hello @VT89,
You're welcome. You can try this code. Basically I've used the ODS statement to output the AncovaPlot dataset. And then I've used Proc SGPLOT to plot the graph. I believe you are after the Ancova graph? You can now change the XAXIS label and also the graph title more easily.
The legend is a little different from before, i.e. there's only the line, instead of the line and marker, but I think that's okay?
ods output ANCOVAPlot = ANCOVAPlot;
PROC GLM Data= work.BN plots=(diagnostics);
CLASS Treatment ;
Model NDFPW = Time |Treatment/solution;
Lsmeans Treatment /cl pdiff adjust=Tukey lines Stderr;
run;
quit;
proc sgplot data = ANCOVAPlot;
scatter x = _X7 y = _YVAR / group = _GROUP_OBS;
series x = _XCONT1 y = _Predicted_FIT / group = _GROUP_FIT name="series_leg" legendlabel = "Treatment";
keylegend "series_leg" / exclude=("");
yaxis label = "NDF(dm), (%)";
xaxis label = "X axis";
run;
Thanks,
Kriss
Hi @VT89 ,
Actually please use this SGPLOT code. It has the legend title too.
proc sgplot data = ANCOVAPlot;
scatter x = _X7 y = _YVAR / group = _GROUP_OBS;
series x = _XCONT1 y = _Predicted_FIT / group = _GROUP_FIT name="series_leg";
keylegend "series_leg" / title = "Treatment" across=2 exclude=("") border;
yaxis label = "NDF(dm), (%)";
xaxis label = "X axis";
run;
Hello@djrisks
I found this code really helpful. I improved on it as follows
Simple Regression Model
The Plot
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.