TEMPLATE Procedure: Creating Crosstabulation Table Templates

Using Crosstabulation Table Templates

Working with the CrossTabFreqs Crosstabulation Table Template

When creating your own crosstabulation table template, you always define the new table with the same name as the existing table, which is Base.Freq.CrossTabFreqs. By default, the existing crosstabulation table that PROC FREQ creates is stored in the Sashelp.Tmplmst template store.
With PROC TEMPLATE, you can create a modified version of Base.Freq.CrossTabFreqs that you can save in a different template store by using the ODS PATH statement. All crosstabulation templates must have the same name. If you want to have multiple crosstabulation templates, put each one in a different template store. Then you can use the ODS PATH statement to add the template store that contains the version of the crosstabulation template that you want to use.
For example, suppose that you have a crosstabulation template in the template store Corporat.Template and another crosstabulation template in Govment.Templat. In the following code, the first ODS PATH statement adds the template store Corporat.Templat. The first PROC FREQ code is then formatted using the crosstabulation table template from Corporat.Templat. The second ODS PATH statement removes Corporat.Templat, and the third ODS PATH statement adds Govment.Templat. The last PROC FREQ step then uses the crosstabulation template from Corporat.Templat.
ods path(prepend) corporat.templat(read);
... proc freq code ...
ods path(remove) corporat.templat;
ods path(prepend) govment.templat;
... proc freq code ...
For more information about the ODS PATH statement, see ODS PATH Statement.

Crosstabulation Table Regions and Corresponding Attributes

When creating a crosstabulation template, you can use attributes to modify individual table regions. The following figure and corresponding table identify the different parts of the crosstabulation table and the attributes that control the style of each part.
Crosstabulation Table Regions That Can Be Modified
Crosstabulation Table Regions That Can Be Modified
Most regions use DEFINE CROSSTABS style attributes to specify a style. The following table shows the style attribute that effects each table region. For complete documentation on DEFINE CROSSTABS attributes, see DEFINE CROSSTABS Attributes. Headers and footers use the STYLE= attribute that is valid for the DEFINE HEADER and DEFINE FOOTER statements. For information about the STYLE= attribute, see DEFINE HEADER and DEFINE FOOTER Attribute Statements.
Table Region and Corresponding Style Attribute
Item
Crosstabulation Table Region
Style Attribute
1
Legend
LEGEND_STYLE=
2
Row variable name
ROWS_HEADER=
3
Row variable value
ROW_VAR_STYLE=
4
Data cell
CELL_STYLE=
5
Column total
COL_TOTAL_STYLE=
6
Footer
STYLE=
7
Grand total
GRAND_TOTAL_STYLE=
8
Row total
ROW_TOTAL_STYLE
9
Column variable name
COLS_HEADER=
10
Header
STYLE=
11
Column variable value
COL_VAR_STYLE=