Displays unique count of field (UNIQUE Operator) Example


Scenario -Print unique values count of a specific field.

In the below example, we are printing the unique values count for country field (2 columns length from 60th column).

INPUT1 - MATEPK.INPUT.PSFILE

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
001  PAWAN         MAINFRAME           JPM       AP        IN
002  SRINIVAS      TESTING             ORACLE    TG        IN
003  SRIDHAR       SAS                 CG        OR        US
004  VENKATESH     ABAP                CSC       CA        IN
005  RAVI          HADOOP              CTS       FL        US
006  PRASAD        HR                  INFOSYS   MI        US
007  RAJA          TESTING             IBM       CA        US

JCL -

----+----1----+----2----+----3----+----4----+----5----+
//MATEPKSP JOB (123),'MATEPK',CLASS=A,MSGCLASS=A,
//             MSGLEVEL=(1,1),NOTIFY=&SYSUID
//*
//STEP01   EXEC PGM=ICETOOL
//INDD     DD DSN=MATEPK.INPUT.PSFILE,DISP=SHR
//TOOLIN   DD *
  UNIQUE FROM(INDD) ON(60,2,CH)
/*
//TOOLMSG  DD SYSOUT=*
//DFSMSG   DD SYSOUT=*
//

TOOLMSG (SDSF SPOOL) - Verify TOOLMSG for the return code of the submitted job.

UNIQUE TOOLMSG

Explaining Example -

  • INDD - Specifies the ddname for input file.
  • TOOLIN DD * - Specifies the ICETOOL statements for DFSORT.
  • TOOLMSG - Specifies where to write the ICETOOL processing messages.
  • DFSMSG - Specifies where to write the DFSORT processing messages.
  • UNIQUE FROM(INDD) ON(60,2,CH) - Prints the number of unique value counts in TOOLMSG based on the selection criteria field from the 60th position of length 2.