STATS

Read syntax diagramSkip visual syntax diagram
STATS syntax – with template

>>-STATS(fieldname,--operator,--literal)-----------------------><

Read syntax diagramSkip visual syntax diagram
STATS syntax – without template

>>-STATS(start,--length,--type,--operator,--literal)-----------><

(Can be used in FASTREXX procedures.)

STATS allows you to do statistical calculations against the values in a field. The calculated value is maintained in a TALLY register and, at the end of the Z Data Tools function, prints on SYSPRINT the TALLY register prefixed by reportliteral.

fieldname
The name you specify must match a field name in the template. For nonunique names, you can specify a name in the form groupname.dataname. Name matching is not case-sensitive. If the name is unqualified, then the first occurrence of the name is used. For dimensioned fields, you can refer to an individual array element by providing a suffix subscript in the form (nn), where nn is a valid subscript for the dimensioned field.
start
Position, in bytes, in the input record at which to start reading the field value.
length
The length of the field in bytes.
type
The data type of the field. The values that can be specified are:
B
Signed binary. If you specify B for type, length must be 2, 4, or 8.
P
Packed decimal. If you specify P for type, length must be between 1 and 16.
UB
Unsigned binary. If you specify UB for type, length must be 2, 4, or 8.
Z
Zoned decimal. This is the default. If you specify Z for type, length must be between 1 and 32 or, if the field contains a separate sign character or leading blanks, between 1 and 3. TALLY ignores leading blanks for zoned decimal fields, allowing simple character numeric fields to be tallied. Records containing only blanks in the target field are ignored. If a separate sign is present, there must be no blanks between the sign and the zoned data.
operator
The statistical processing to be applied to the field. The values that can be specified are:
AVG
Calculate the average of the field values.
TOTAL
Accumulate the total of the field values.
literal
A literal string that is prefixed to the calculated values printed on SYSPRINT.

Example

Calculate the average value of all the loans recorded in the data set.

STATS('loan-value','AVG', 'Average value of all loans')