TABULATE Procedure

Example 5: Customizing Row and Column Headings

Features:

TABLE statement: labels

Data set: ENERGY
Formats: REGFMT.

DIVFMT.

USETYPE.

Details

This example shows how to customize row and column headings. A label specifies text for a heading. A blank label creates a blank heading. PROC TABULATE removes the space for blank column headings from the table.

Program

proc tabulate data=energy format=dollar12.;
   class region division type;
   var expenditures;
    table region*division,
         type='Customer Base'*expenditures=' '*sum=' '
         / rts=25;
   format region regfmt. division divfmt. type usetype.;
   title 'Energy Expenditures for Each Region';
   title2 '(millions of dollars)';
run;

Program Description

Specify the table options.The FORMAT= option specifies DOLLAR12. as the default format for the value in each table cell.
proc tabulate data=energy format=dollar12.;
Specify subgroups for the analysis.The CLASS statement identifies Region, Division, and Type as class variables.
   class region division type;
Specify the analysis variable.The VAR statement specifies that PROC TABULATE calculate statistics on the Expenditures variable.
   var expenditures;
Define the table rows and columns.The TABLE statement creates a row for each formatted value of Region. Nested within each row are rows for each formatted value of Division. The TABLE statement also creates a column for each formatted value of Type. Each cell that is created by these rows and columns contains the sum of the analysis variable Expenditures for all observations that contribute to that cell. Text in quotation marks specifies headings for the corresponding variable or statistic. Although Sum is the default statistic, it is specified here so that you can specify a blank for its heading.
    table region*division,
         type='Customer Base'*expenditures=' '*sum=' '
Specify the row title space.RTS= provides 25 characters per line for row headings.
         / rts=25;
Format the output.The FORMAT statement assigns formats to Region, Division, and Type.
   format region regfmt. division divfmt. type usetype.;
Specify the titles.
   title 'Energy Expenditures for Each Region';
   title2 '(millions of dollars)';
run;

Output

The heading for Type contains text that is specified in the TABLE statement. The TABLE statement eliminated the headings for Expenditures and Sum.
Energy Expenditures for Each Region