With ODS Graphics, statistical procedures can directly produce graphs as well as tables. Graphs are integrated with tables in the ODS output. ODS Graphics is available to procedures in SAS/STAT®, Base SAS®, SAS/ETS®, SAS/QC®, and other SAS® products and is provided with Base SAS. You might want to make changes to a graph, which cannot be done using graphics options provided by the procedure. There are several general approaches to making changes to ODS graphs. The methods vary in ease of use, interactivity, and permanence of changes.
Note that global TITLE statements do not affect these titles. The GrTitle macro can be used to change titles of ODS graphs produced by procedures. The GrTitle macro is an autocall macro and can be called in your SAS session without any need to download and install it. Use of the GrTitle macro is discussed and illustrated in SAS Note 70375. Additional discussion and an example can be seen in the "ODS Graphics Template Modification" chapter in the SAS/STAT User's Guide.
The ODS Graphics Editor can be used to make one-time changes to a single ODS graph that are not possible using existing options or suboptions in the procedure. The ODS Graphics Editor can make changes to the elements of ODS graphs, such as titles, footnotes, line types, colors, plotting symbols, and adding annotation. These changes are shown as you make them. The modifications made are not retained and therefore affect only the edited graph and not any future graphs. The ODS Graphics Editor is not available in SAS® Viya®.
To make graphs available for editing, include the SGE=ON option in an ODS HTML or ODS LISTING statement as shown below. Then run the procedure and double-click the icon of the editable graph in the Results window to open the graph in the Editor. Or right-click the graph icon and select Open as shown below.
The graph opens in the ODS Graphics Editor. For information about using the Editor, see "ODS Graphics Editor" in the "Statistical Graphics Using ODS" chapter of the SAS/STAT User's Guide or see the SAS ODS Graphics Editor: User's Guide for your release of SAS®9.
Often, the easiest and most versatile way to modify a variety of elements of an ODS graph is to save the data that produces the graph and then re-create the graph as desired using the SGPLOT procedure. Once done, you can retain the code that you develop and use it to make the same or similar modifications in future graphs.
If the only change needed is to add the associated BY group to each of the multiple graphs produced by a procedure using a BY statement, simply add the same BY statement in the SGPLOT code that reproduces the graphs. This adds a title line to each graph that shows the associated BY group.
To save the graph data, specify the name of the graph in an ODS OUTPUT statement. Graph names can be found in "ODS Graphics" in the Details section of the documentation for the procedure that produces the ODS graph. Or simply right-click the plot's icon in the Results window (as shown above) and select Properties. You can then use the capabilities of PROC SGPLOT to present the graph as you like. Several examples are presented in the notes listed below. For more information, see the documentation for PROC SGPLOT in the SAS ODS Graphics: Procedures Guide.
Examples:
To make changes affecting the appearance of an ODS graph in future runs of the procedure, you need to modify the ODS template that governs the graph. Graph template definitions are written in the Graph Template Language (GTL) in the TEMPLATE procedure.
While developing custom graphs is beyond the scope of services that are provided by SAS Technical Support, Kuhfeld (2009) provides a macro that simplifies many template changes. Also see the "ODS Graphics Template Modification" chapter of the SAS/STAT User's Guide for your release of SAS and the references below.
More discussion on ODS Graphics and templates can be found in the SAS Blogs and SAS Communities.
__________
Resources and References
Gallery of PROC SGPLOT example plots
Cartier, J. 2006. "A Programmer's Introduction to the Graphics Template Language." Proceedings of the Thirty-first Annual SAS Users Group International Conference. Paper 262-31. Cary, NC: SAS Institute Inc.
Kuhfeld, W. F. 2009. "Modifying ODS Statistical Graphics Templates in SAS 9.2." Proceedings of the 2015 SAS Global Forum. Paper 323-2009. Cary, NC: SAS Institute Inc.
Matange, S. 2016. Clinical Graphs Using SAS. Cary, NC: SAS Institute Inc.
Matange, S. and Heath, D. 2011. Statistical Graphics Procedures by Example: Effective Graphs Using SAS. Cary, NC: SAS Institute Inc.
Rodriguez, R. N. and T. E. Balan. 2006. "Creating Statistical Graphics in SAS 9.2: What Every Statistical User Should Know." Proceedings of the Thirty-first Annual SAS Users Group International Conference. Paper 192-31. Cary, NC: SAS Institute Inc.
Yeh, S. 2005. "Customizing ODS Statistical Graphics." Proceedings of the Thirtieth Annual SAS Users Group International Conference. Paper 183-30. Cary, NC: SAS Institute Inc.
Zender, C. and C. Truxillo. 2005. "Customizing ODS Statistical Graphs." Proceedings of the Thirtieth Annual SAS Users Group International Conference. Paper 239-30. Cary, NC: SAS Institute Inc.
Additional ODS graphics references
Product Family | Product | System | SAS Release | |
Reported | Fixed* | |||
SAS System | SAS/STAT | All | n/a | |
SAS System | SAS/QC | All | n/a | |
SAS System | SAS/OR | All | n/a | |
SAS System | SAS/ETS | All | n/a |
Type: | Usage Note |
Priority: | low |
Topic: | Query and Reporting ==> Creating Reports ==> Graphical SAS Reference ==> ODS (Output Delivery System) Common Programming Tasks Analytics ==> Statistical Graphics |
Date Modified: | 2023-11-28 16:21:08 |
Date Created: | 2006-09-06 13:25:54 |