COMPUTE (calculate mathematical expression)


COMPUTE calculates a mathematical expression and places the results in a variable.

The expression specified by the COMPUTE statement uses CMRSTATS, CMRDETL, or CTGDTLrecords as variables.

The SELECT statement declares the CMRSTATS, CMRDETL, or CTGDETL records that are used as COMPUTE variables. The SELECT statement usually precedes the COMPUTE statement in a PRL program.

The results assigned to the variable by COMPUTE can be reported by naming the variable in the USING statement. The COMPUTE statement usually appears before the USING statement in a PRL program.

Syntax

COMPUTE V1 = expression

where

  • V1 is a 1- to 8-byte user-specified alphanumeric character string beginning with an alphabetic character.
  • expression sets the user-specified variable to the results of the calculation as expressed by the = sign with any of the following operators:

    +

    adds two record variables together

    -

    subtracts one record variable from another

    *

    multiplies record variables

    /

    divides record variables

Whole numbers with signs, commas, or decimal points can be used with any of these operators. They also can be used alone to represent real numbers.

Usage

When the variable being computed is used with DETAIL, SUMMARY, or USING statements, a DEFINE statement should be inserted before the COMPUTE statement.

The computations on printouts can result in the maximum of a 16-digit mathematical expression.

In the following example, COMPUTE uses a simple addition expression and places the results in TOTALPG. The results of the computation are reported for each selected record until the end of file. The USING statement specifies the user-defined TOTALPG variable as a column heading.

Example
SET TITLE = 'DAILY PAGING AND TASK ANALYSIS'
SELECT TYPE CC RECORDS FROM CMRSTATS

  COMPUTE TOTALPG = T6FSPGIN + T6FSPGOU
  USING CMRDATE T6FSPGIN T6FSPGOU TOTALPG T6FTRNCT

SUMMARY
REPORT
END




 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*