Actually I thought of a much better way to do this with DFSORT's ICETOOL given that you say all of the duplicates are grouped together. This version only requires one copy pass rather than two sort passes.
//S1 EXEC PGM=ICETOOL //TOOLMSG DD SYSOUT=* //DFSMSG DD SYSOUT=* //IN DD * EEEE 01 EEEE 02 BBBB 01 CCCC 01 CCCC 02 CCCC 03 CCCC 04 AAAA 01 AAAA 02 AAAA 03 DDDD 01 /* //OUT DD SYSOUT=* //TOOLIN DD * * Select first record with each key. SELECT FROM(IN) TO(OUT) ON(1,4,CH) FIRST USING(CTL1) /* //CTL1CNTL DD * * Force copy instead of sort since dup records are * grouped together. OPTION COPY /* Frank Yaeger - DFSORT Team (IBM) Specialties: ICETOOL, IFTHEN, OVERLAY, Symbols, Migration => DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort/ ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO Search the archives at http://bama.ua.edu/archives/ibm-main.html