The COMPUTAB Procedure |
Program Flow |
This section describes in detail the different steps in PROC COMPUTAB execution.
Before the COMPUTAB procedure reads in data or executes programming statements, the columns list from the COLUMNS statements and the rows list from the ROWS statements are used to set up a matrix of all columns and rows in the report. This matrix is called the COMPUTAB data table (CDT). When you define columns and rows of the CDT, the COMPUTAB procedure also sets up corresponding variables in working storage called the program data vector (PDV) for programming statements. Data values reside in the CDT but are copied into the program data vector as they are needed for calculations.
The input block copies input observations into rows or columns of the CDT. By default, observations go to columns; if the data set is not transposed (the NOTRANS option is specified), observations go to rows of the report table. The input block consists of all executable statements before any ROWxxxxx: or COLxxxxx: statement label. Use programming statements to perform calculations and select a given observation to be added into the report.
The input block is executed once for each observation in the input data set. If there is no input data set, the input block is not executed. The program logic of the input block is as follows:
Determine which variables, row or column, are selector variables and which are data variables. Selector variables determine which rows or columns receive values at the end of the block. Data variables contain the values that the selected rows or columns receive. By default, column variables are selector variables and row variables are data variables. If the input data set is not transposed (the NOTRANS option is specified), the roles are reversed.
Initialize nonretained program variables (including selector variables) to 0 (or missing if the INITMISS option is specified). Selector variables are temporarily associated with a numeric data item supplied by the procedure. Using these variables to control row and column selection does not affect any other data values.
Transfer data from an observation in the data set to data variables in the PDV.
Execute the programming statements in the input block by using values from the PDV and storing results in the PDV.
Transfer data values from the PDV into the appropriate columns of the CDT. If a selector variable for a row or column has a nonmissing and nonzero value, multiply each PDV value for variables used in the report by the selector variable and add the results to the selected row or column of the CDT.
A column block is executed once for each row of the CDT. The program logic of a column block is as follows:
Indicate the current row by setting the corresponding row variable in the PDV to 1 and the other row variables to missing. Assign the current row number to the special variable _ROW_.
Move values from the current row of the CDT to the respective column variables in the PDV.
Execute programming statements in the column block by using the column values in the PDV. Here new columns can be calculated and old ones adjusted.
Move the values back from the PDV to the current row of the CDT.
A row block is executed once for each column of the CDT. The program logic of a row block is as follows:
Indicate the current column by setting the corresponding column variable in the PDV to 1 and the other column variables to missing. Assign the current column number to the special variable _COL_.
Move values from the current column of the CDT to the respective row variables in the PDV.
Execute programming statements in the row block by using the row values in the PDV. Here new rows can be calculated and old ones adjusted.
Move the values back from the PDV to the current column of the CDT.
See the section Controlling Execution within Row and Column Blocks.
Any number of column blocks and row blocks can be used. Each can include any number of programming statements.
The values of row variables and column variables are determined by the order in which different row-block and column-block programming statements are processed. These values can be modified throughout the COMPUTAB procedure, and final values are printed in the report.
Copyright © SAS Institute, Inc. All Rights Reserved.