Previous Page | Next Page

TEMPLATE Procedure: Creating Crosstabulation Table Templates

Concepts: Crosstabulation Output and the TEMPLATE Procedure


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


What Makes the Crosstabulation Table Unique?

Crosstabulation tables produced by PROC FREQ are different from other tables that SAS produces. Most other tables are composed 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.


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 show 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 on 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=

Previous Page | Next Page | Top of Page