Page 1 of 1

sort unique records

PostPosted: Fri Nov 12, 2010 1:52 am
by shankarhosur
My input file is something like below,

334219 40878002733100420100723A00000046218MOR
334219 42947178433100420100723A00000071316GOR
444219 42947178433100420100723F00000035658GOR
444219 43331199733100420100723A00000027897GOR
555219 47572143533100420100723A00000066664GOR
555219 21472494133100620100723A00000002760GOR

First 6 byte is plan number. I want to filter only unique records based on plan number. The output would be something like,

334219 42947178433100420100723A00000071316GOR
444219 42947178433100420100723F00000035658GOR
555219 47572143533100420100723A00000066664GOR

Is it possible using SORT?

Re: sort unique records

PostPosted: Fri Nov 12, 2010 5:51 am
by Frank Yaeger
Your example does not show filtering by "unique" records. It shows keeping one record with each key. If you want to keep the first record with each key, you can use a DFSORT/ICETOOL job like this:

//S1    EXEC  PGM=ICETOOL                                 
//TOOLMSG DD SYSOUT=*                                     
//DFSMSG  DD SYSOUT=*                                     
//IN DD *                                                 
334219  40878002733100420100723A00000046218MOR             
334219  42947178433100420100723A00000071316GOR             
444219  42947178433100420100723F00000035658GOR             
444219  43331199733100420100723A00000027897GOR             
555219  47572143533100420100723A00000066664GOR             
555219  21472494133100620100723A00000002760GOR             
//OUT DD SYSOUT=*                                         
//TOOLIN   DD   *                                         
SELECT FROM(IN) TO(OUT) ON(1,6,CH) FIRST                   
/*                                                         


If you want to do something else, you need to do a better job of explaining exactly what it is you want to do.

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:

http://www.ibm.com/support/docview.wss? ... g3T7000080

Re: sort unique records

PostPosted: Fri Nov 12, 2010 6:24 am
by shankarhosur
How to catch the rest of the records in different file means skipped records.

Re: sort unique records

PostPosted: Fri Nov 12, 2010 6:40 am
by shankarhosur
I got it..!!

//S1    EXEC  PGM=ICETOOL                     
//TOOLMSG DD SYSOUT=*                         
//DFSMSG  DD SYSOUT=*                         
//IN DD *                                     
334219  40878002733100420100723A00000046218MOR
334219  42947178433100420100723A00000071316GOR
334219  42947178433100420100723A00000071316GOR
334219  42947178433100420100723A00000071316GOR
444219  42947178433100420100723F00000035658GOR
444219  43331199733100420100723A00000027897GOR
555219  47572143533100420100723A00000066664GOR
555219  21472494133100620100723A00000002760GOR
//OUT1 DD SYSOUT=*                             
//OUT2 DD SYSOUT=*                             
//TOOLIN   DD   *                             
SELECT FROM(IN) TO(OUT1) ON(1,6,CH) FIRST -   
DISCARD(OUT2)                                 
/*

Re: sort unique records

PostPosted: Fri Nov 12, 2010 6:57 am
by dick scherrer
Good to hear it is working - congrats :)

Thank you for posting your solution,

d