Defining Report Layout

ROWS and COLUMNS statements define the rows and columns of the report. The order of row and column names in these statements determines the order of rows and columns in the report. Additional ROWS and COLUMNS statements can be used to specify row and column formatting options.

The following statements select and order the variables from the input data set and produce the report in Figure 9.4:

proc computab data=report;
   rows travel advrtise salary;
run;

Figure 9.4 Report Produced Using a ROWS Statement
Monthly Divisional Expense Report

                 COL1       COL2       COL3       COL4       COL5       COL6    
                                                                                
  TRAVEL     10500.00  112000.00    6800.00    8200.00   99000.00    6000.00    
  ADVRTISE    6500.00   90000.00   18500.00   12000.00   86000.00   16000.00    
  SALARY     95000.00  668000.00  105000.00   91000.00  602000.00   96000.00    

When a COLUMNS statement is not specified, each observation becomes a new column. If you use a COLUMNS statement, you must specify to which column each observation belongs by using program statements for column selection. When more than one observation is selected for the same column, values are summed.

The following statements produce Figure 9.5:

proc computab data= report;
   rows travel advrtise salary insure;
   columns a b c;
   *----select column for company division,
        based on value of compdiv----*;
   a = compdiv = 'A';
   b = compdiv = 'B';
   c = compdiv = 'C';
run;

The statement A=COMPDIV=’A’; illustrates the use of logical operators as a selection technique. If COMPDIV=’A’, then the current observation is added to the A column. See SAS Language: Reference, Version 6, First Edition for more information about logical operators.

Figure 9.5 Report Produced Using ROWS and COLUMNS Statements
Monthly Divisional Expense Report

                                     A          B          C                    
                                                                                
                   TRAVEL     18700.00  211000.00   12800.00                    
                   ADVRTISE   18500.00  176000.00   34500.00                    
                   SALARY    186000.00  1270000.0  201000.00                    
                   INSURE      3900.00   11100.00   17500.00