TEMPLATE Procedure: Overview |
Using the TEMPLATE Procedure |
The TEMPLATE procedure enables you to customize the appearance of your SAS output. For example, you can create, extend, or modify existing templates for various types of output:
ODS then uses these templates to produce formatted output.You can also use the TEMPLATE procedure to navigate and manage the templates stored in template stores. Here are some tasks that you can do with PROC TEMPLATE:
What Can You Do with the TEMPLATE Procedure? |
This output shows the use of a customized table template for the Moments output object from PROC UNIVARIATE. The program used to create the modified table template does the following:
Listing Output (Customized Moments Table) from PROC UNIVARIATE
Custom Moments Table 1 The UNIVARIATE Procedure Variable: CityPop_90 (1990 metropolitan pop in millions) Moments --------------------------------------------------------------- N 51 Sum Weights 51 Mean 3.87701961 Sum Observations 197.728 Std Deviation 5.16465302 Variance 26.6736408 Skewness 2.87109259 Kurtosis 10.537867 Uncorrected SS 2100.27737 Corrected SS 1333.68204 Coeff Variation 133.21194 Std Error Mean 0.72319608 ---------------------------------------------------------------
Customized HTML Output (Customized Moments Table) from PROC UNIVARIATE (Viewed with Microsoft Internet Explorer)
When you are working with styles (definitions), you are more likely to modify a style that SAS supplies than to write a completely new style. The following output uses the Styles.Default template that SAS provides, but includes changes made to the style in order to customize the output's appearance. HTML Output (Viewed with Microsoft Internet Explorer) shows changes made to both the contents file and the body file in the HTML output. In the contents file, the modified style makes changes to the following:
In the body file, the modified style makes changes to the following:two of the colors in the color list. One of these colors is used as the foreground color for the table of contents, the byline, and column headings. The other is used for the foreground of many parts of the body file, including SAS titles and footnotes.
the presentation of the data in the table by changing attributes like cellspacing, rules, and borderwidth
HTML Output (Viewed with Microsoft Internet Explorer)
Tagsets are used to create custom markup. You can create your own tagsets, extend existing tagsets, or modify a tagset that SAS supplies. This display shows the results from a new tagset TAGSET.MYTAGS.
MYTAGS.CHTML Output (Viewed with Microsoft Internet Explorer)
STATGRAPH templates are used to create output called ODS Graphics. For complete information see SAS/GRAPH: Graph Template Language User's Guide.
The following code creates the STATGRAPH template MyGraphs.Regplot, which creates the following graph.
proc template; define statgraph mygraphs.regplot; begingraph; entrytitle "Regression Plot"; layout overlay; modelband "mean"; scatterplot x=height y=weight; regressionplot x=height y=weight / clm="mean"; endlayout; endgraph; end; run; ods listing style=analysis; ods graphics / reset imagename="reg" width=500px; proc sgrender data=sashelp.class template=mygraphs.regplot; run;
Graph Created with a STATGRAPH Template
The TEMPLATE procedure enables you to customize the appearance of crosstabulation (contingency) tables that are created with the FREQ procedure. By default, crosstabulation tables are formatted according to the CrossTabFreqs template that SAS provides. However, you can create a customized CrossTabFreqs table template by using the TEMPLATE procedure with the DEFINE CROSSTABS statement.
This output shows the use of a customized crosstabulation table template for the CrossTabFreqs table. The program used to create the modified crosstabulation table template does the following:
modifies table regions
customizes legend text
modifies headers and footers
modifies variable labels used in headers
customizes styles for cellvalues
The Backward Compatibility of ODS Templates |
ODS templates are not binary compatible between SAS versions. However, with some templates, you can use a template created with an earlier version of SAS with a later version of SAS. The following table lists the ODS templates and whether they are forward or backward compatible between SAS versions.
ODS Template | Backward Compatible | Forward Compatible |
---|---|---|
table | no | yes |
crosstabs | no | yes |
style | no | yes * |
tagset | no | no |
ODS Graphics | no | no |
* Styles that use inheritance may not be compatible forwards or backwards. See Inheritance Compatibility across Versions for more information.
If you would like to use a template created with a later version of SAS with an earlier version of SAS, you might be able to extract the template source and use it to compile the template in the earlier release.
Copyright © 2008 by SAS Institute Inc., Cary, NC, USA. All rights reserved.