TEMPLATE Procedure: Overview

Using the TEMPLATE Procedure

What Can You Do with the TEMPLATE Procedure?

Modify a Table Template That a SAS Procedure Uses

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:
  • creates and edits a copy of the default table template
  • edits a header within the table template
  • sets column attributes to enhance the appearance of the HTML output
For the code that creates the following default and customized output, see Editing a Table Template That a SAS Procedure Uses.
Default Moments Table
Default Moments Table
Customized HTML Output (Customized Moments Table) from PROC UNIVARIATE (Viewed with Microsoft Internet Explorer)
Customized HTML Output (Customized Moments Table) from PROC UNIVARIATE (Viewed with Microsoft Internet Explorer)

Modify a Style

When you are working with styles, you are more likely to modify a style that SAS supplies than to write a completely new style. The following output uses the Styles.HTMLBlue template that SAS provides, but includes changes made to the style in order to customize the output's appearance. For the code that creates this output, see Using the CLASS Statement.
In the contents file, the modified style makes changes to the following:
  • the text of the header and the text that identifies the procedure that produced the output
  • the colors for some parts of the text
  • the font size for some parts of the text
  • the spacing in the list of entries in the table of contents
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 font size for titles and footnotes.
  • the font style for headers.
  • the presentation of the data in the table by changing attributes like cellspacing, rules, and borderwidth.
HTML Output (Viewed with Microsoft Internet Explorer)
HTML Output (Viewed with Microsoft Internet Explorer)

Create Your Own Tagset

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.
To see the customized CHTML tagset, view the source from your Web browser by selecting Viewthen selectSource from your browser's toolbar.
MYTAGS.CHTML Output (Viewed with Microsoft Internet Explorer)
MYTAGS.CHTML Output (Viewed with Microsoft Internet Explorer)

Create a Template-Based Graph

STATGRAPH templates are used to create output called ODS Graphics. For complete information, see the SAS 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;
The following display shows a scatter plot with an overlaid regression line and confidence limits of the mean for the HEIGHT and WEIGHT variables of a data set.
Graph Created with a STATGRAPH Template
Graph Created with a STATGRAPH Template

Modify a Crosstabulation Table

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. For the SAS code that creates this output, see Creating a Crosstabulation Table Template with a Customized Legend.
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
Customized Crosstabulation Table Template for the CrossTabFreqs Table
Customized Crosstabulation Table Template for the CrossTabFreqs Table