TABULATE Procedure

Example 9: Creating Multipage Tables

Features:
TABLE statement:
ALL class variable
BOX=
CONDENSE
INDENT=
page expression
Data set: ENERGY
Formats: REGFMT.

DIVFMT.

USETYPE.

Details

This example creates a separate table for each region and one table for all regions. By default, PROC TABULATE creates each table on a separate page, but the CONDENSE option places them all on the same page.

Program

proc tabulate data=energy format=dollar12.;
   class region division type;
   var expenditures;
   table region='Region: ' all='All Regions',
   division all='All Divisions',
         type='Customer Base'*expenditures=' '*sum=' '
         / rts=25 box=_page_ condense indent=1;
   format region regfmt. division divfmt. type usetype.;
   title 'Energy Expenditures for Each Region and All Regions';
   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 pages.The page dimension of the TABLE statement creates one table for each formatted value of Region and one table for all regions. Text in quotation marks provides the heading for each page.
   table region='Region: ' all='All Regions',
Define the table rows.The row dimension creates a row for each formatted value of Division and a row for all divisions. Text in quotation marks provides the row headings.
   division all='All Divisions',
Define the table columns.The column dimension of the TABLE statement creates a column for each formatted value of Type. Each cell that is created by these pages, 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.
         type='Customer Base'*expenditures=' '*sum=' '
Specify additional table options.RTS= provides 25 characters per line for row headings. BOX= places the page heading inside the box above the row headings. CONDENSE places as many tables as possible on one physical page. INDENT= eliminates the row heading for Division. (Because there is no nesting in the row dimension, there is nothing to indent.)
         / rts=25 box=_page_ condense indent=1;
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 and All Regions';
   title2 '(millions of dollars)';
run;

Output

Energy Expenditures for Each Region and All Regions