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 that 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 modify only 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)
Product Family | Product | System | SAS Release | |
Reported | Fixed* | |||
SAS System | N/A | Aster Data nCluster on Linux x64 | ||
DB2 Universal Database on AIX | ||||
DB2 Universal Database on Linux x64 | ||||
Netezza TwinFin 32-bit SMP Hosts | ||||
Netezza TwinFin 32bit blade | ||||
Netezza TwinFin 64-bit S-Blades | ||||
Netezza TwinFin 64-bit SMP Hosts | ||||
Teradata on Linux | ||||
Cloud Foundry | ||||
64-bit Enabled AIX | ||||
64-bit Enabled HP-UX | ||||
64-bit Enabled Solaris | ||||
ABI+ for Intel Architecture | ||||
AIX | ||||
HP-UX | ||||
HP-UX IPF | ||||
IRIX | ||||
Linux | ||||
Linux for AArch64 | ||||
Linux for x64 | ||||
Linux on Itanium | ||||
OpenVMS Alpha | ||||
OpenVMS on HP Integrity | ||||
Solaris | ||||
Solaris for x64 | ||||
Tru64 UNIX | ||||
z/OS | ||||
z/OS 64-bit | ||||
IBM AS/400 | ||||
OpenVMS VAX | ||||
N/A | ||||
Android Operating System | ||||
Apple Mobile Operating System | ||||
Chrome Web Browser | ||||
Macintosh | ||||
Macintosh on x64 | ||||
Microsoft Windows 10 | ||||
Microsoft Windows 7 | ||||
Microsoft Windows 8 Enterprise 32-bit | ||||
Microsoft Windows 8 Enterprise x64 | ||||
Microsoft Windows 8 Pro 32-bit | ||||
Microsoft Windows 8 Pro x64 | ||||
Microsoft Windows 8 x64 | ||||
Microsoft Windows Server 2008 R2 | ||||
Microsoft Windows Server 2012 R2 Datacenter | ||||
Microsoft Windows Server 2012 R2 Std | ||||
Microsoft® Windows® for 64-Bit Itanium-based Systems | ||||
Microsoft Windows Server 2003 Datacenter 64-bit Edition | ||||
Microsoft Windows Server 2003 Enterprise 64-bit Edition | ||||
Microsoft Windows XP 64-bit Edition | ||||
Microsoft® Windows® for x64 | ||||
OS/2 | ||||
SAS Cloud | ||||
Microsoft Windows 8.1 Enterprise 32-bit | ||||
Microsoft Windows 8.1 Enterprise x64 | ||||
Microsoft Windows 8.1 Pro 32-bit | ||||
Microsoft Windows 8.1 Pro x64 | ||||
Microsoft Windows 11 | ||||
Microsoft Windows 95/98 | ||||
Microsoft Windows 2000 Advanced Server | ||||
Microsoft Windows 2000 Datacenter Server | ||||
Microsoft Windows 2000 Server | ||||
Microsoft Windows 2000 Professional | ||||
Microsoft Windows NT Workstation | ||||
Microsoft Windows Server 2003 Datacenter Edition | ||||
Microsoft Windows Server 2003 Enterprise Edition | ||||
Microsoft Windows Server 2003 Standard Edition | ||||
Microsoft Windows Server 2003 for x64 | ||||
Microsoft Windows Server 2008 | ||||
Microsoft Windows Server 2008 for x64 | ||||
Microsoft Windows Server 2012 Datacenter | ||||
Microsoft Windows Server 2012 Std | ||||
Microsoft Windows Server 2016 | ||||
Microsoft Windows Server 2019 | ||||
Microsoft Windows Server 2022 | ||||
Microsoft Windows XP Professional | ||||
Windows 7 Enterprise 32 bit | ||||
Windows 7 Enterprise x64 | ||||
Windows 7 Home Premium 32 bit | ||||
Windows 7 Home Premium x64 | ||||
Windows 7 Professional 32 bit | ||||
Windows 7 Professional x64 | ||||
Windows 7 Ultimate 32 bit | ||||
Windows 7 Ultimate x64 | ||||
Windows Millennium Edition (Me) | ||||
Windows Vista | ||||
Windows Vista for x64 |
Type: | Usage Note |
Priority: | |
Topic: | Analytics ==> Statistical Graphics SAS Reference ==> Macro |
Date Modified: | 2023-09-21 10:26:00 |
Date Created: | 2023-09-12 18:18:31 |