Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
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

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 corresponding 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;
   run;

 
                                                                                
                                                                                
                                                                                
                               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               
Figure 9.6: Report Produced Using Row and Column Blocks

Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.