Sorts a data set to one or more output data sets.

Syntax: -

Sorts the indd data set to the outdd data sets (up to 10).

The DFSORT control statements in xxxxCNTL are used if USING(xxxx) is specified.

DFSORT control statements and options can be used to copy a subset of the input records, reformat records for output and so on.

Required Operands: -


Specifies the ddname of the input data set.

DD statements must supply for the ddnames specified.


Used for a JOINKEYS application.

JKFROM must provide a USING(xxxx) operand.

In xxxxCNTL, a JOINKEYS statement must provide with F1=ddname1 for the F1 file and a JOINKEYS statement with F2=ddname2 for the F2 file, as well as JOIN and REFORMAT statements as needed.


Specifies the first 4 characters of the ddname (xxxxCNTL) for the DFSORT control statement data set.

DD statement must supply for xxxxCNTL if USING(xxxx) specified.

TO, USING, or TO and USING must be specified.

Optional Operands: -

TO -

Specifies the ddnames of 1 to 10 output data sets.

DD statements must supply for the ddnames you specify.

TO, USING, or TO and USING must be specified.


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

Example: -

Below example to sort the employee records based on employee state(from 50th column of length 2).

Input: -


JCL: -

***************************** Top of Data ******************************
//             NOTIFY=&SYSUID                                           
//STEP01   EXEC PGM=ICETOOL                                             
//INDD     DD DSN=MTHUSR.INPUT.DATASET,DISP=SHR                         
//OUTDD    DD DSN=MTHUSR.OUTPUT.DATASET1,                               
//            DISP=(NEW,CATLG,DELETE),                                  
//            SPACE=(TRK,(1,1),RLSE),UNIT=SYSDA,                        
//            DCB=(DSORG=PS,RECFM=FB,LRECL=80,BLKSIZE=800)              
//TOOLIN   DD *                                                         
  SORT   FROM(INDD) TO(OUTDD) USING(CTL1)                               
//CTL1CNTL DD *                                                         
  SORT FIELDS=(50,2,CH,A)                                               
//DFSMSG   DD SYSOUT=*                                                  
**************************** Bottom of Data ****************************




Explaining Solution: -

  • INDD - Specifies the ddname for input dataset.
  • OUTDD - Specifies the ddname for output dataset.
  • TOOLIN DD * - Specifies the ICETOOL statements for DFSORT.
  • CTL1CNTL DD * - Specifies the DFSORT statements for processing.
  • TOOLMSG - Specifies ICETOOL message data set.
  • DFSMSG - Specifies DFSORT message data set.
  • SORT FROM(INDD) TO(OUTDD) USING(CTL1) - Sorts the indd records and copies to OUTDD based on the selection criteria in CTL1.
  • SORT FIELDS=(50,2,CH,A) - Sorts the records in ascending order based on the data from 50th position of length 2.