Previous Page | Next Page

TEMPLATE Procedure: Overview

Introduction to the TEMPLATE Procedure


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?


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:

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)

[Customized HTML Output (Customized Moments Table) from PROC UNIVARIATE (Viewed with Microsoft Internet Explorer)]


Modify a Style

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:

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.

MYTAGS.CHTML Output (Viewed with Microsoft Internet Explorer)

 Note about figure

[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 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

 Note about figure

[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.

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:

[untitled graphic]


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 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.

Previous Page | Next Page | Top of Page