Thanks Sri, that is just what I need. Peter
-----Original Message----- From: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> On Behalf Of Sri h Kolusu Sent: Tuesday, September 22, 2020 2:24 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: SORT question: How to both remove records from a file AND write removed records to a 2nd output? > In one pass of an input file is there a way to use SORT to both remove > identified records from an input file AND write those removed records > to a second output file? Peter, You don't need 2 passes of data, you can tag the records that match your identification and then use that tag to filter the records on OUTFIL. Some thing like this //STEP0100 EXEC PGM=SORT //SYSOUT DD SYSOUT=* //SORTIN DD * ABC - DROP THIS RECORD DEF - PICK THIS RECORD EFG - PICK THIS RECORD XYZ - DROP THIS RECORD ZZZ - DROP THIS RECORD //PICKREC DD SYSOUT=* //DROPREC DD SYSOUT=* //SYSIN DD * OPTION COPY INREC IFTHEN=(WHEN=(1,3,SS,EQ,C'DEF,EFG'), OVERLAY=(81:C'A')) OUTFIL FNAMES=PICKREC, INCLUDE=(81,1,CH,EQ,C'A'), BUILD=(1,80) OUTFIL FNAMES=DROPREC,SAVE, BUILD=(1,80) /* The PICKREC file will have the following records DEF - PICK THIS RECORD EFG - PICK THIS RECORD The DROPREC file will have the following records ABC - DROP THIS RECORD XYZ - DROP THIS RECORD ZZZ - DROP THIS RECORD For VB files, make sure that you have the Indicator right after the RDW so that you retain the variable length records as is Something like this //SYSIN DD * OPTION COPY INREC IFTHEN=(WHEN=INIT, BUILD=(1,4, $ RDW X, $ ID TAG 5)), $ DATA AS-IS IFTHEN=(WHEN=(6,3,SS,EQ,C'DEF,EFG'), OVERLAY=(05:C'A')) OUTFIL FNAMES=PICKREC, INCLUDE=(05,1,CH,EQ,C'A'), BUILD=(1,04, $ RDW 6) $ DATA AS-IS OUTFIL FNAMES=DROPREC,SAVE, BUILD=(1,04, $ RDW 6) $ DATA AS-IS /* -- This message and any attachments are intended only for the use of the addressee and may contain information that is privileged and confidential. If the reader of the message is not the intended recipient or an authorized representative of the intended recipient, you are hereby notified that any dissemination of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail and delete the message and any attachments from your system. ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN