Previous Topic: Work Fields and the DEFINE(K) Statement

Next Topic: Work Fields and the DECODE Statement


Work Fields and the COMPUTE Statement

Work fields that were not previously defined in a DEFINE or DECODE statement are created and initialized when first encountered in a COMPUTE statement.

The work field is assigned format characteristics based on your explicit specifications, or defaults to PACKED format, 4 bytes in LENGTH, and 0 SCALING. The work field retains its format characteristics throughout the run.

The work field is initialized with zeros or blanks, depending on whether the data format is numeric or character. The value of the work field changes depending on the COMPUTE logic, but is always reset to zero or blanks for each new record, except if given the suffix (K).

Example:

COMPUTE CTRA EQ CTRA + 1,
CTRB(B)(.2) EQ CPU TIME,
CTRC EQ JOB NAME,
CTRD(C)(8) EQ STEP NAME

CTRA defaults to PACKED, 4 BYTES, 0 SCALING. Its initial value is 0; first record value is 1; second value is 1; third record value is 1, etc.

CTRB is defined as BINARY, 4 BYTES, 2 DECIMAL PLACES. Its initial value is 0; first record value is the first input record's CPU TIME; second record value is the second input record's CPU TIME, etc.

CTRC causes a diagnostic error because JOB NAME is defined in the glossary with a CHARACTER format and CTRC defaults to PACKED format.

CTRD is assigned the format characteristics of CHARACTER, 8 BYTES. Its initial value is blanks; first record value is the first input record's STEP NAME; second record value is the second input record's STEPNAME; third record value is the third input record's STEP NAME, etc.

The use of the suffix (K) after the data item name causes the definition of the work field to proceed in the same manner as described above, except that CA JARS Wizard does not reset the work field. The work field retains its value until explicitly altered by a COMPUTE statement.

Example:

COMPUTE CTRA(K) EQ CTRA + 1

CTRA defaults to be PACKED, 4 BYTES, 0 SCALING. Its initial value is 0; first record value is 1; second record value is 2; third record value is 3, etc.