TABULATE Procedure

Example 6: Summarizing Information with the Universal Class Variable ALL

Features:

PROC TABULATE statement options: FORMAT=

TABLE statement:
ALL class variable
concatenation (blank operator)
format modifiers
grouping elements (parentheses operator)
Data set: ENERGY
Formats: REGFMT.

DIVFMT.

USETYPE.

Details

This example shows how to use the universal class variable ALL to summarize information from multiple categories.

Program

proc tabulate data=energy format=comma12.;
   class region division type;
   var expenditures;
table region*(division all='Subtotal')
         all='Total for All Regions'*f=dollar12.,
         type='Customer Base'*expenditures=' '*sum=' '
         all='All Customers'*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 COMMA12. as the default format for the value in each table cell.
proc tabulate data=energy format=comma12.;
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;
table region*(division all='Subtotal')
         all='Total for All Regions'*f=dollar12.,
         type='Customer Base'*expenditures=' '*sum=' '
         all='All Customers'*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 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;

Output

The universal class variable ALL provides subtotals and totals in this table.
Energy Expenditures for Each Region