Many informative graphs can be produced by analytic procedures in SAS/STAT®, SAS/ETS®, and SAS/QC® either by default or by using options such as the PLOTS= option in the PROC statement, options in other statements, or by using statements such as EFFECTPLOT, LSMEANS, and SLICE that are available in many procedures. While the default presentation of these graphs is designed to be immediately useful and attractive, you might want to make certain modifications to a specific graph to suit your needs. The options and statements that produce a graph generally offer additional options that allow some changes to the graph. You should first examine the documentation of the statement or option that produced the graph to determine whether there is an available option to make the desired change.
One of the most common needs is to change the title or titles displayed at the top of the ODS graph. These titles are not affected by the global TITLE statement. If the option or statement that produces the graph does not provide a way to modify the graph title, you can use the GrTitle macro to provide the information you need to change the title. The following shows how you can use the macro. Additional information and examples can be found in the "ODS Graphics Template Modification" chapter in the SAS/STAT® User's Guide and in SAS Note 22542.
Modifications to graphs other than title changes can be done by various means, as discussed in SAS Note 24529.
Consider the data and final model in the example titled "Logistic Modeling with Categorical Predictors" in the PROC LOGISTIC chapter of the SAS/STAT® User's Guide. The following statements fit the model and request a plot of odds ratio estimates as well as an effect plot showing the predicted probabilities from the model at each value of the predictors. The ODS TRACE ON; and ODS TRACE OFF; statements are used to display the name of the template that produces each plot:
ods trace on; proc logistic data=Neuralgia plots(only)=oddsratio; class Treatment Sex / param=ref; model Pain(event="No") = Treatment Sex Age; effectplot / at(Sex=all) noobs; run; ods trace off;
The SAS log displays the following lines that are produced by the ODS TRACE ON; statement.
Output Added:
-------------
Name: ORPlot
Label: Odds Ratios with 95% Wald Confidence Limits
Template: Stat.Logistic.Graphics.ORPlot
Path: Logistic.ORPlot
-------------
Output Added:
-------------
Name: SliceFitPanel
Label: Sliced Fit Panel 1
Template: Stat.Logistic.Graphics.SLICEFITPanel
Path: Logistic.EffectPlots.EffectPlots.SliceFitPanel
Below are the odds ratio and effect plots from PROC LOGISTIC:
In order to change the default titles on these graphs, the GrTitle macro is used as shown below to temporarily redefine the templates that make the two graphs. The modified templates are saved in WORK.TEMPLAT in your WORK library. Note that the template name, not the path name, from the above trace output is used in the PATH= option in the macro. If you want to only modify one graph, then the NODELETE option is not needed. However, if you already have modified templates in your WORK library, then use the NODELETE option in each GrTitle call to prevent them being deleted:
%grtitle(path=Stat.Logistic.Graphics.ORPlot) %grtitle(path=Stat.Logistic.Graphics.SLICEFITPanel, options=nodelete)
The following information produced by the GrTitle macro is displayed in the SAS log. It shows the names of macro variables that you can use to specify the graph titles. Since different macro variables are used by the template in different circumstances, you will need to try assigning a different value to each one to see which is needed for your graphs:
Stat.Logistic.Graphics.ORPlot -> Common.Graphics.OddsRatioPlot
Graphics_OddsRatioPlot
Graphics_OddsRatioPlot2
Graphics_OddsRatioPlot3
Stat.Logistic.Graphics.SLICEFITPanel -> Stat.Lmr.Graphics.SLICEFITPanel
Lmr_SLICEFITPanel
Lmr_SLICEFITPanel2
Lmr_SLICEFITPanel3
Lmr_SLICEFITPanel4
Lmr_SLICEFITPanel5
After defining macro variables using each of the names displayed by the GrTitle macro and rerunning the PROC LOGISTIC step, it is found that Graphics_OddsRatioPlot controls the title in the odds ratio plot and Lmr_SLICEFITPanel4 controls the title in the effect plot. As a result the following code is all that is needed to redraw the graphs with new titles:
%let graphics_oddsratioplot=Treatment, Sex, Age Odds Ratios; %let lmr_slicefitpanel4=Predicted Probabilities at Treatment, Sex, Age; proc logistic data=Neuralgia plots(only)=oddsratio; class Treatment Sex / param=ref; model Pain(event="No") = Treatment Sex Age; effectplot / at(Sex=all) noobs; run;
Note the changed title in both plots:
Since the modified templates created by the GrTitle macro are placed in the WORK folder, they will be deleted and the graphs will appear with their default titles in your next SAS session. However, if you want to change them back to their default titles in your current SAS session, you can specify the following GrTitle call to delete these templates, and all others in the WORK folder, immediately:
%grtitle(options=delete)