BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
VT89
Fluorite | Level 6

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. 

1 ACCEPTED SOLUTION

Accepted Solutions
djrisks
Barite | Level 11

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;

View solution in original post

8 REPLIES 8
djrisks
Barite | Level 11

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

VT89
Fluorite | Level 6

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. 

SampleTypeTreatmentTimePlantPortionndfpw
BNS_I0F3.326147
BNS_I0F4.085303
BNS_I0F7.798459
BNS_I0F1.854164
BNS_I0F8.403201
BNS_I0FNA
BNS_I3F4.378336
BNS_I3F5.970024
BNS_I3F4.991754
BNS_I6F6.077845
BNS_I6F5.119463
BNS_I6F7.625552
BNS_I9F4.898555
BNS_I9F5.667297
BNS_I9F5.862422
BNS_I12F8.046645
BNS_I12F8.79686
BNS_I12F8.624618
BNS_NI0F1.854164
BNS_NI0F8.403201
BNS_NI0FNA
BNS_NI0F3.326147
BNS_NI0F4.085303
BNS_NI0F7.798459
BNS_NI3F7.225144
BNS_NI3F6.853081
BNS_NI3F6.329218
BNS_NI3F8.708655
BNS_NI6F4.530356
BNS_NI6F6.884661
BNS_NI6F9.946883
BNS_NI6F8.250516
BNS_NI9F6.647393
BNS_NI9F6.343426
BNS_NI9F5.817403
BNS_NI9F5.767742
BNS_NI12F7.546846
BNS_NI12F6.657135
BNS_NI12F6.755493
BNS_NI12F3.543603

 

I really appreciate any help you can provide. Thank you again. 

djrisks
Barite | Level 11

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 

 

djrisks
Barite | Level 11

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;
VT89
Fluorite | Level 6
Awesome! Thank you so much again, Kriss. I really appreciate your help. This works well. The proc template would have been a hard way for me to go, at least I know sgplot use.
djrisks
Barite | Level 11
You're welcome! I'm glad it helped! Yes ,the SGPLOT is more flexible and easier to adapt.
ugoagwup
Fluorite | Level 6

Hello@djrisks

I found this code really helpful. I improved on it as follows

 

Simple Regression Model

Proc glm data= Tdata;
ods output FitPlot = Fit_Plot;
where LBTEST in("Alanine Aminotransferase");
model LFTvalues = bckTrans_auc/ solution;
run;

 

The Plot 

proc sgplot data = Fit_Plot;
  scatter x = _X3 y = _YVAR ;  
  series x = _XCONT1 y = _Predicted_FIT;
  keylegend "series_leg" / exclude=("");
  yaxis label = "AST (Units per liter)";
  xaxis label = "AUC(h*ng/mL)";
run;
The above code just gives me a scattered plot with a regression line. I would like some help with improvement on this script to give me the attached sample plot where the regression line is aligned within the bounds of 95%CI.  I will appreciate any assistance I can get.
 

 

ugoagwup
Fluorite | Level 6

Regression plotRegression plot

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 2524 views
  • 3 likes
  • 3 in conversation