TEMPLATE Procedure: Creating Table Templates

Concepts: Tabular Output and the TEMPLATE Procedure

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.

Viewing the Contents of a Table Template

To view the contents of a table template, use the SAS windowing environment, the command line, or the TEMPLATE procedure.
  • Using the SAS Windowing Environment
    1. From the menu, select Viewthen selectResults.
    2. In the Results window, select the Results folder. Right-click and select Templates to open the Templates window.
    3. Double-click Sashelp.Tmplmst to view the contents of that item store or directory.
    4. Double-click a directory to view the list of subdirectories and table templates that you want to view. For example, the Base SAS table template Summary is the default template store for the summary tables created in the MEANS and SUMMARY procedures. Double-click the Base directory, and then double-click the Summary table.
  • Using the Command Line
    1. To view the Templates window, submit this command: odstemplates
      The Templates window contains the item stores Sasuser.Templat and Sashelp.Tmplmst.
    2. When you double-click an item store, such as Sashelp.Tmplmst, that item store expands to list the directories where ODS templates are stored. The templates that SAS provides are in the item store Sashelp.Tmplmst.
    3. To view the table templates that SAS provides, double-click the item store that contains a table template, such as Base.
    4. Right-click the table template, such as Summary, and select Open. The table template is displayed in the Template Browser window.
  • Using the TEMPLATE Procedure. The SOURCE statement writes the source code for the specified template to the SAS log. For example, if to view the source code for all the objects in Base SAS, submit this code.
    proc template;
    source base;