Copies subset of the records (SUBSET Operator)


SUBSET operator selects records from a dataset by keeping or removing the header, relative, or trailer records. It also include or exclude the records using the selection criteria for the first or last 'n' records. DISCARD(savedd) is used to save the records that do not meet the selection criteria.

Syntax -

SUBSET Operator

Required Operands


  • FROM - specifies ddname of the input file. It is mandatory when FROM operand is coded.
  • TO - specifies 1 to 10 ddnames of output files. TO and USING operands can code at the same time.
  • DISCARD - Specifies the ddname of the output dataset for the not selected records.
  • KEEP, REMOVE – Specifies whether the records that meet the criteria are kept or removed.
  • INPUT, OUTPUT – Specifies whether the criteria applied to the input records or output records.

Optional Operands


  • VSAMTYPE - specifies the record format for a VSAM input file. It should be either F (fixed-length) or V (variable-length) record processing.
  • HEADER, FIRST, TRAILER, LAST, RRN – Specifies the header records (first u records), trailer records (last v records) and/or relative records to be kept or removed. 'u', 'v', 'q', and 'r' values can be 1 to 999999999999999.
  • USING - specifies the first 4-characters of the ddname (xxxxCNTL) for the DFSORT control statement. XXXX name is the user-defined name. Either TO, USING, or both operands can code at the same time.

Example -


Scenario - Copy only data records (exclude header and footer).

INPUT - MATEPK.INPUT.PSFILE1

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
ENO  NAME          TECHNOLOGY          COMPANY   STATE     COUNTRY
========================================================================
001  PAWAN         MAINFRAME           JPM       AP        IN
002  SRINIVAS      TESTING             ORACLE    TG        IN
003  SRIDHAR       SAS                 CG        OR        US
004  VENKATESH     ABAP                CSC       CA        US
005  RAVI          HADOOP              CTS       FL        US
006  PRASAD        HR                  INFOSYS   MI        US
007  RAJA          TESTING             IBM       CA        US
========================================================================
TOTAL NUMBER OF RECORDS: 007

JCL -

----+----1----+----2----+----3----+----4----+----5----+
...
//STEP01   EXEC PGM=ICETOOL
//INDD     DD DSN=MATEPK.INPUT.PSFILE1,DISP=SHR
//OUTDD    DD DSN=MATEPK.OUTPUT.PSFILESS,
//            DISP=(NEW,CATLG,DELETE),VOLUME=SER=DEVHD4,
//            SPACE=(TRK,(1,1),RLSE),UNIT=SYSDA,
//            DCB=(DSORG=PS,RECFM=FB,LRECL=80,BLKSIZE=800)
//TOOLIN   DD *
  SUBSET FROM(INDD) TO(OUTDD) REMOVE OUTPUT HEADER(2) TRAILER(2)
/*
...

OUTPUT - MATEPK.OUTPUT.PSFILESS

----+----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        US
005  RAVI          HADOOP              CTS       FL        US
006  PRASAD        HR                  INFOSYS   MI        US
007  RAJA          TESTING             IBM       CA        US