CONTROL Statements


DFSORT control statements can logically divided into two types.

  1. Primary control statements
  2. Secondary control statements

Primary control statements -


DFSORT control statements are the key to executing sorting, merging, and copying operations. The primary control statements include:

  1. SORT - It sorts the records in a dataset according to the fields we define.
  2. MERGE - It combines multiple sorted input datasets into a single sorted dataset.
  3. OPTION COPY - It copies data from an input dataset to an output dataset without sorting.

The primary control statements are mandatory for DFSORT. Two primary control statements should not be coded together. These can be coded in the combination with secondary control statements.

Secondary control statements -


The secondary control statements provides the additional processing options to primary control statements. These statements can only be coded along with the primary control statements. Different secondary control statements are explained below -

  • Including or Omitting records -
    • INCLUDE selects records that meet the coded conditions.
    • OMIT excludes records that meet the coded conditions. The remaining records which are not satisfies the criteria will be copied to output file.
    • OUTFIL used to route the filtered records to a single or multiple output files.
  • Reformatting and editing records -
    • INREC reformats the data before sorting, merging or copying.
    • OUTREC reformats the data after sorting, merging or copying.
    • OUTFIL used to route the reformatted or edited records to a single or multiple output files.
  • Producing multiple outputs, reports and converting records -
    • OUTFIL used to route the output records to a single or multiple output files.
  • Joining two files -
    • JOINKEYS - allows us to join two datasets by matching key fields from both.
    • REFORMAT - Describes the fields from the two files to be included in the joined records. Optionally an indicator of where the key was found ('B' for both files, '1' for file1 only and '2' for file2 only).
  • Additional functions and options -
    • ALTSEQ - specifies the changes to the ALTSEQ table to be used for SORT, MERGE, INCLUDE or OMIT fields with format AQ. Also for INREC, OUTREC, and OUTFIL fields with TRAN=ALTSEQ, and for INREC, OUTREC, and OUTFIL fields with format AQ in logical expressions.
    • DEBUG - specifies for various diagnostic options.
    • END - causes DFSORT to discontinue reading SYSIN, SORTCNTL, or DFSPARM.
    • RECORD - can be used to supply length and type information.
    • SUM - specifies numeric summary fields of all records with equal control fields are summed in one record and that the other records are deleted.