TEMPLATE Procedure: Creating Tabular Output |
Using the TEMPLATE Procedure to Create or Customize Tabular Output |
The TEMPLATE procedure enables you to customize the tabular appearance of your SAS output. With the TEMPLATE procedure, you can create and modify table templates, column templates, header templates, and footer templates. The Output Delivery System then uses these templates to produce customized tabular output for better data presentations and reports than what you get with the default SAS output. You can also create you own master tables using templates.
By default, ODS output is formatted according to the various definitions or templates that the procedure or DATA step specify. However, you can customize existing tabular output templates, or create your own new tabular output templates, by using the TEMPLATE procedure with these statements.
Customization | Element Modified | Statement |
---|---|---|
Column presentation | Column template |
DEFINE COLUMN |
Table footer | Footer template |
DEFINE FOOTER |
Table header | Header template |
DEFINE HEADER |
Single output object | Table template |
DEFINE TABLE |
An existing template for a table, column, header, or footer | Table, column, header, footer |
EDIT |
Terminology |
For definitions of terms used in this section, see Terminology: TEMPLATE Procedure.
What You Can Do With a Table Template |
By default, ODS uses the table template specified by the procedure or DATA step to create ODS output. For example, the following display shows the default listing output of the Moments output object created by PROC UNIVARIATE. The second display shows the default RTF output of the same output object.
Listing Output from PROC UNIVARIATE (Default Moments Table)
RTF Output of Sales Statistics from PROC UNIVARIATE (Default Moments Table)
With PROC TEMPLATE, you can change many of the table elements and obtain a customized format for the output objects. Here are some of the elements that you can change:
Note: Not all table template changes affect all destinations. For example, font changes are ignored in the LISTING destination.
The following displays show the results of using a customized table template that changes the first table header attributes, sets underlining and overlining in the table, and changes the amount of spacing between rows.
Listing Output from PROC UNIVARIATE (Customized Moments Table)
RTF Output of Sales Statistics from PROC UNIVARIATE (Customized Moments Table)
Comparing the Edit of an Existing Table Template with Creating a New Table Template |
To change a table template without completely redefining it, use an EDIT statement. Using the EDIT statement keeps all of the templates and attributes that already exist in the table template, and changes only the templates or attributes specified in the EDIT statement. By default, the modified table template is stored in SASUSER.TEMPLAT with the same name as the table template specified in the EDIT statement.
To create a new table template, use the DEFINE TABLE statement. A table template cannot be a parent to itself because creating a table through inheritance causes an error, and then the template must be deleted. When you create a new table template, only the columns, headers, footers, and table attributes that you define exist in the new table template.
Note: If you edit an existing table or define a new table with the same name as an existing table, then the table template is stored in the SASUSER.TEMPLAT item store. This table template is used, by default, unless you specify that the Sashelp.Tmplmst path is searched first. However, you can use the ODS PATH statement to store the template elsewhere and access it differently. See the ODS PATH Statement for more information.
Copyright © 2008 by SAS Institute Inc., Cary, NC, USA. All rights reserved.