TABULATE Procedure

Example 8: Indenting Row Headings and Eliminating Horizontal Separators

Features:

PROC TABULATE statement options: NOSEPS

TABLE statement options: INDENT=

Data set: ENERGY
Formats: REGFMT.

DIVFMT.

USETYPE.

Details

This example shows how to condense the structure of a table by doing the following:
  • removing row headings for class variables
  • indenting nested rows underneath parent rows instead of placing them next to each other
  • eliminating horizontal separator lines from the row titles and the body of the table

Program

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

Program Description

Open the LISTING destination.The INDENT argument does not indent nested row headings for HTML output. The output will be captured as a listing with page numbering and date turned off.
options nodate nonumber;
ods listing;
Specify the table options.The FORMAT= option specifies DOLLAR12. as the default format for the value in each table cell. NOSEPS eliminates horizontal separator lines from row titles and from the body of the table.
proc tabulate data=energy format=dollar12. noseps;
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 in all dimensions 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 and indention value.RTS= provides 25 characters per line for row headings. INDENT= removes row headings for class variables, places values for Division beneath values for Region rather than beside them, and indents values for Division four spaces.
         / rts=25 indent=4;
Format the output.The FORMAT statement assigns formats to the variables 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;
Close the LISTING destination.
ods listing close;

Output

NOSEPS removes the separator lines from the row titles and the body of the table. INDENT= eliminates the row headings for Region and Division and indents values for Division underneath values for Region.
Energy Expenditures for Each Region