TEMPLATE Procedure: Creating Crosstabulation Table Templates

Concepts: Crosstabulation Output and the TEMPLATE Procedure

What Makes the Crosstabulation Table Unique?

Crosstabulation tables produced by PROC FREQ are different from other tables that SAS produces. Most other tables consist of rows and columns with one value for each row-column combination. However, the crosstabulation table has these distinctive characteristics:
multiple values per cell
The crosstabulation table can have up to nine values for each row-column combination, depending on the options specified by the TABLES statement. Most other tables that SAS creates have only one value for each row-column combination.
legend
Crosstabulation tables have a separate box, which is called a legend, to contain the labels for the cellvalues. No other table that SAS produces has a legend.
row variable column
The far left column contains the row variable values. Each value in this column provides a label for the row in the same way that the column variable values provide labels for the columns.
column variable headers
Each value in these headers provides a label for the columns of the table.
row and column totals
The far right column contains the row totals. The bottom row contains the column totals.
grand total cell
The grand total cell is the last cell of the row and column totals.

Comparison between Table Templates and Crosstabulation Table Templates

Because the crosstabulation table is unique, the syntax used to create crosstabulation templates differs significantly from other table templates.
  • The crosstabulation template has no parent template, and it cannot serve as a parent to another template.
  • Most of the attributes, such as CENTER and PANELS=, that are defined for classic table templates are not defined in the crosstabulation table template.
  • Crosstabulation table templates use DEFINE CELLVALUE blocks instead of the DEFINE COLUMN blocks that are used in other table templates.
  • Crosstabulation table templates use the CELLVALUE statement instead of the COLUMN statement that is used in other table templates.
  • Both crosstabulation table templates and other table templates use DEFINE HEADER and DEFINE FOOTER blocks. However, the attributes that can be used in each of these blocks differ.
  • DEFINE HEADER and DEFINE FOOTER blocks can contain multiple TEXT statements only in crosstabulation table templates. ODS then chooses which TEXT statement to use at execution time.
  • A TEXT statement can specify a WHERE expression only in crosstabulation table templates. ODS uses the WHERE expression to determine whether to use the TEXT statement text as the header text.
  • The CELL_STYLE, COLS_HEADER, COL_TOTAL_STYLE, COL_VAR_STYLE, GRAND_TOTAL_STYLE, LEGEND_STYLE, ROWS_HEADER, and ROW_VAR_STYLE attributes are unique to the crosstabulation table.
  • The ROWS_HEADER and COLS_HEADER attributes are unique to the crosstabulation table.
  • The NVAR, MVAR, and TRANSLATE-INTO statements are not supported for crosstabulation templates.