The COMPUTAB Procedure

Adding Computed Rows and Columns

In addition to the variables and observations in the input data set, you can create additional rows or columns by using SAS programming statements in PROC COMPUTAB. You can do the following:

  • modify input data and select columns in the input block

  • create or modify columns in column blocks

  • create or modify rows in row blocks

The following statements add one computed row (SUM) and one computed column (TOTAL) to the report in Figure 9.5. In the input block the logical operators indicate the observations that correspond to each column of the report. After the input block reads in the values from the input data set, the column block creates the column variable TOTAL by summing the columns A, B, and C. The additional row variable, SUM, is calculated as the sum of the other rows. The result is shown in Figure 9.6.

proc computab data= report;
   rows travel advrtise salary insure sum;
   columns a b c total;
   a = compdiv = 'A';
   b = compdiv = 'B';
   c = compdiv = 'C';
   colblk: total = a + b + c;
   rowblk: sum   = travel + advrtise + salary + insure;

Figure 9.6: Report Produced Using Row and Column Blocks

Monthly Divisional Expense Report

                               A          B          C      TOTAL               
             TRAVEL     18700.00  211000.00   12800.00  242500.00               
             ADVRTISE   18500.00  176000.00   34500.00  229000.00               
             SALARY    186000.00  1270000.0  201000.00  1657000.0               
             INSURE      3900.00   11100.00   17500.00   32500.00               
             SUM       227100.00  1668100.0  265800.00  2161000.0