Summary -

In this topic, we described about the below sections -

Prints messages containing the minimum, maximum, average and total for specified numeric fields in a data set. The average is calculated by dividing the total by the record count and rounding down to the nearest integer.

Syntax -

STATS Operator

Required Operands: -

FROM -

Specifies the ddname of the input data set. DD statement must supply for the ddname specified.

ON -

Specifies a field to be used for this operation. From 1 to 10 ON fields can be specified.

(p,m,f) gives the position, length and format of a numeric or character field. A field must not extend beyond position 32752 or the end of the record.

VLEN is equivalent to ON(1,2,BI) for variable-length records, represents the record length for each record.

Optional Operands: -

VSAMTYPE -

Specifies the record format for a VSAM input data set (F or V).

LMSG -

Specifies the minimum, maximum, average and total for all numeric fields are printed using messages that display 31 digits.

Example: -

Below example to display statistics of the employee records for the employee salary(from 65th column of length 6).

Input: -

MTHUSR.INPUT.DATASET2 -

STATS Operator

JCL: -

----+----1---+---2---+----3----+----4---+---5---+---6---+---7--
***************************** Top of Data ***************************
//MTHUSRR JOB (123),'MTHUSR',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),         
//             NOTIFY=&SYSUID                                           
//*                                                                     
//STEP01   EXEC PGM=ICETOOL                                             
//INDD     DD DSN=MTHUSR.INPUT.DATASET2,DISP=SHR                        
//TOOLIN   DD *                                                         
  STATS  FROM(INDD) ON(65,6,ZD)                                         
/*                                                                      
//TOOLMSG  DD DSN=MTHUSR.OUTPUT.TOOLMSG1,DISP=SHR                       
//DFSMSG   DD SYSOUT=*                                                  
//                                                                      
**************************** Bottom of Data *************************

STATS Operator

OUTPUT: -

TOOLMSG: -

STATS Operator

Explaining Solution: -

  • INDD - Specifies the ddname for input dataset.
  • TOOLIN DD * - Specifies the ICETOOL statements for DFSORT.
  • TOOLMSG - Specifies ICETOOL message data set.
  • DFSMSG - Specifies DFSORT message data set.
  • STATS FROM(INDD) ON(65,6,ZD) - Prints the maximum, minimum, average etc of the field specified in criteria from 65th position and of length 6.