Statistical Graphics Using ODS |
Editing Templates |
You can modify the format and appearance of a particular graph by doing the following:
Modify its template definition (source program).
Submit the revised template to create a new compiled template.
Ensure that the ODS search path finds and uses your new template.
Template stores are designated read-only (such as SASHELP.Tmplmst) or updatable (such as SASUSER.Templat).
If you view the templates in an updatable template store from the Templates window, you can select Open or Edit from the pop-up menu. Either the Template Browser or Template Editor window opens. In the Template Editor window, you can make changes and submit the code directly. For read-only templates or when you select Open, the Template Browser window opens and you must copy the definition to an editor window to make changes. Since templates supplied by SAS are in the read-only SASHELP library, an easy way to obtain an editable program file is to use the SOURCE statement with the FILE= option in PROC TEMPLATE to write the template definition to a file as follows:
proc template; source Stat.REG.Graphics.ResidualPlot / file="residtpl.sas"; run;
By default, the file is saved in the SAS current folder. Alternatively, you can omit the slash and the FILE= option and copy and paste the source from the SAS log into an editor. Either way, you must add a PROC TEMPLATE statement before the generated source statements and a RUN statement after the END statement before you submit your modified definition.
Graph definitions are self-contained and do not support inheritance or "parenting" as do table definitions. Consequently, the EDIT statement in PROC TEMPLATE is not supported for graph definitions.
Here are some important points about what you can and cannot change in a template supplied by SAS while preserving its overall functionality:
Do not change the template name. A statistical procedure can access only a predefined list of templates. If you change the name, the procedure cannot find your template. You must keep the original name and make sure that it is in a template store that is read before SASHELP.Tmplmst. You control this with the ODS PATH statement (see the section The Default Template Stores and the Template Search Path, the section Saving Customized Templates, and subsequent sections for more information about the template search path and the ODS PATH statement).
Do not change the names of columns. The underlying data object contains predefined column names that you must use. Be very careful if you change how a column is used in a template. Usually, columns are not interchangeable.
Do not change the names of DYNAMIC variables. Procedures set values only for a predefined list of dynamic variables. Changing dynamic variable names can lead to runtime errors. Do not add dynamic variables, because the procedure cannot set their values. A few procedures document additional dynamic variables that can be defined in the template if you want to add more information to the output, such additional statistics in an inset table. See the section Modifying the Layout and Adding a New Inset Table for an example.
Do not change the names of statements (for example, from a SCATTERPLOT to a NEEDLEPLOT or other type of plot).
You can change any of the following:
You can add macro variables that behave like dynamic variables. They are resolved at the time that the statistical procedure is run, and not at the time that the template is compiled. They are defined with an MVAR or NMVAR statement at the beginning the template. You can set the value of each macro variable with a %LET statement before the statistical procedure is run. See Example 21.10. You can also move a variable from a DYNAMIC statement to an MVAR or NMVAR statement if you want to set it yourself rather than letting the procedure set it.
You can change the graph size.
You can change graph titles, footnotes, axis labels, and any other text that appears in the graph.
You can change which plot features are displayed.
You can change axis features, such as grid lines, offsets, view ports, tick value formatting, and so on.
You can change the content and arrangement of insets (small tables of statistics embedded in some graphs).
You can change the legend location, contents, border, background, title, and so on.
See the SAS/GRAPH Template Language Reference for information about the syntax of the statements in the Graph Template Language.
Copyright © SAS Institute, Inc. All Rights Reserved.