SUBSET Operator
SUBSET Operator (for Experienced)
Summary
For basic information, go through the SUBSET Operator (for Beginners)
- SUBSET operator selects records from a dataset by keeping or removing the header, relative, or trailer records.
- SUBSET operators also include or exclude the records using the selection criteria for the first or last 'n' records or based on RRN (relative record numbers).
- DISCARD(savedd) is used to save the records that do not meet the selection criteria.
- DISCARD(savedd) may be used with or without TO(outdd).
- The DFSORT control statements in xxxxCNTL are used if USING(xxxx) is specified.
Syntax -

Required Operands
FROM -
- FROM parameter specifies ddname of the input file.
- indd DD statement is mandatory if FROM operand specified.
TO -
- TO operand specifies 1 to 10 ddnames of output files.
- outdd DD statement is mandatory if TO operand specified
- Either TO, USING, or both operands can code at the same time.
DISCARD -
- Specifies the ddname of the output dataset for the not selected records.
- DD statement should be for the DISCARD ddname.
- TO(outdd) and DISCARD(savedd) may be used together or separately.
KEEP, REMOVE –
- Indicates whether the records that meet the criteria are kept or removed.
INPUT, OUTPUT –
- Indicates whether the criteria applied to the input records or output records.
Optional Operands
VSAMTYPE -
- VSAMTYPE operand specifies the record format for a VSAM input file (F or V).
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.
- RRN(q,*) can specify relative records q through the last record.
- SUBSET allows up to 300 RRNs or a range of RRNs.
- 'u', 'v', 'q', and 'r' values can be 1 to 999999999999999.
USING -
- USING operand specifies the first 4-characters of the ddname (xxxxCNTL) for the DFSORT control statement file.
- XXXX name is the user-defined name.
- xxxxCNTL DD statement is mandatory if USING(xxxx) is specified.
- 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
BROWSE MATEPK.INPUT.PSFILE1 Line 00000000 Col 001 080
Command ===> Scroll ===> CSR
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
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
******************************** Bottom of Data ********************************
JCL -
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
//MATEPKSS JOB (123),'MATEPK',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),
// NOTIFY=&SYSUID
//*
//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)
/*
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//
**************************** Bottom of Data ****************************
OUTPUT - MATEPK.OUTPUT.PSFILESS
BROWSE MATEPK.OUTPUT.PSFILESS Line 00000000 Col 001 080
Command ===> Scroll ===> CSR
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
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
******************************** Bottom of Data ********************************
TOOLMSG (SDSF SPOOL) - Verify TOOLMSG for the return code of the submitted job.
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9
********************************* TOP OF DATA ********************************************
1ICE600I 0 DFSORT ICETOOL UTILITY RUN STARTED
ICE650I 0 VISIT http://www.ibm.com/storage/dfsort FOR ICETOOL PAPERS, EXAMPLES AND MORE
ICE632I 0 SOURCE FOR ICETOOL STATEMENTS: TOOLIN
ICE630I 0 MODE IN EFFECT: STOP
SUBSET FROM(INDD) TO(OUTDD) REMOVE OUTPUT HEADER(2) TRAILER(2)
ICE627I 0 DFSORT CALL 0001 FOR COPY FROM INDD TO OUTFIL COMPLETED
ICE602I 0 OPERATION RETURN CODE: 00
ICE601I 0 DFSORT ICETOOL UTILITY RUN ENDED - RETURN CODE: 00
******************************** BOTTOM OF DATA ******************************************
Explaining Solution -
- INDD - Specifies the ddname for input file.
- OUTDD - Specifies the ddname for output 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.
- SUBSET FROM(INDD) TO(OUTDD) REMOVE OUTPUT HEADER(2) TRAILER(2)- Selects the subset of the records from the input which ignores first 2 records and last 2 records.