TEMPLATE Procedure: Overview

Introduction to the TEMPLATE Procedure

Introduction to 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:
  • styles
  • tables
  • crosstabulation tables
  • columns
  • headers
  • footers
  • tagsets
  • ODS Graphics
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:
  • edit an existing template
  • create links to an existing template
  • change the location where you write new templates
  • search for existing templates
  • view the source code of a template

Terminology: TEMPLATE Procedure

These terms frequently appear in discussions of PROC TEMPLATE:
aggregate storage location
is a location on an operating system that can contain a group of distinct files. Different host operating systems call an aggregate grouping of files different names, such as a directory, a maclib, or a partitioned data set. The standard form for referencing an aggregate storage location from within SAS is fileref(name), where fileref is the entire aggregate and (name) is a specific file or member of that aggregate.
event
specifies the text that the markup destination produces when the specified event occurs. For example, the template of an event called ROW might specify to place the appropriate tags for starting a row at the beginning of an event and the appropriate tags for ending a row at the end of the event. SAS procedures that generate ODS output use a standard set of events, which you can customize with the TEMPLATE procedure.
graph template
describes the contents and structure of a single-cell or multi-cell graph.
item store
is a member of a SAS library. An item store is a hierarchical file system that is implemented as a single physical file. An item store can contain directories and files (called items) similar to the file systems in the UNIX and Windows operating environments. An item store is referenced by a two-level name: a libref and the name of the item store in the SAS library that the libref references. For example, the SAS registry is stored in two items stores, Sasuser.Registry and Sashelp.Registry.
style (template)
describes how to display the presentation aspects (color, font face, font size, and so on) of your SAS output. A style determines the overall appearance of the documents that use it. Each style consists of style elements.
style element
is a collection of style attributes that apply to a particular part of the output. For example, a style element can contain instructions for the presentation of column headings or for the presentation of the data inside cells. Style elements can also specify default colors and fonts for output that uses the style. Each style attribute specifies a value for one aspect of the presentation. For example, the BACKGROUND= attribute specifies the color for the background of an HTML table, and the FONTSTYLE= attribute specifies whether to use a Roman, a slant, or an italic font.
table template
describes how to display the output for a tabular output object. (Most ODS output is tabular.) A table template determines the order of table headers and footers, the order of columns, and the overall appearance of the output object that uses it. Each table template contains or references table elements.
table element
is a collection of attributes that apply to a particular column, header, or footer. Typically, these attributes specify something about the data rather than about its presentation. For example, FORMAT= specifies the SAS format to use in a column. However, some attributes describe presentation aspects of the data.
Note: You can also define table elements such as columns, headers, and footers outside of a table template. Any table template can then reference these table elements. For more information about defining columns, headers, and footers outside of the table template, see TEMPLATE Procedure: Creating Table Templates.
tagset
specifies instructions for creating a markup language for your SAS output. The resulting output contains embedded instructions in order to define layout and some content. Each tagset contains event templates and event attributes that control the generation of the output. SAS provides tagsets for a variety of markup languages. With the TEMPLATE procedure, you can modify any of these SAS tagsets, or you can create your own tagsets.
template store
is an item store that stores templates that were created by the TEMPLATE procedure. Templates that SAS provides are in the item store Sashelp.Tmplmst. You can store templates that you create in any template store where you have write access.
Note: A template store can contain multiple levels known as directories. When you specify a template store in the ODS PATH statement, however, you specify a two-level name that includes a libref and the name of a template store in the SAS library that the libref references.

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.
Compatibility of ODS Templates 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 might 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.