compare two fields within one file

IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

compare two fields within one file

Postby venkyjm » Tue Dec 15, 2009 1:08 am


I would like to compare two fields within one file F1 and if there is a mismatch between two fields in a row then write it out to a output file F2. can be this done using sort utility. I did search the forum but i coudn't find something similar to my question, please point me if there is already a thread discussing about this topic.

           pos(1-15)          pos(16-30)
rec1:   allanxsmith        allanJsmith
rec2:   rainxdeer          rainxdeer
rec3:   kimxlarry          kimslarry
rec4:   robertxhenry       robertxhenry

in the above example rec1 and rec3 has to be written to the output file since those fields dont match.

Posts: 1
Joined: Tue Dec 15, 2009 12:35 am
Has thanked: 0 time
Been thanked: 0 time

Re: compare two fields within one file

Postby Frank Yaeger » Tue Dec 15, 2009 4:15 am

You can use a DFSORT job like the following to do what you asked for:

//S1    EXEC  PGM=SORT                       
//SYSOUT    DD  SYSOUT=*                     
//SORTIN DD *                                 
allanxsmith    allanJsmith                   
rainxdeer      rainxdeer                     
kimxlarry      kimslarry                     
robertxhenry   robertxhenry                   
//SORTOUT DD SYSOUT=*                         
//SYSIN    DD    *                           
  OPTION COPY                                 
  INCLUDE COND=(1,15,CH,NE,16,15,CH)         

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from: ... g3T7000080
Frank Yaeger - DFSORT Development Team (IBM) -
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at
User avatar
Frank Yaeger
Global moderator
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times



  • Related topics
    Last post