Sort first 'N' records for each Key in a group of DUP keys



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

Sort first 'N' records for each Key in a group of DUP keys

Postby gopal0802 » Sun Jun 21, 2009 8:41 am

Hi, I need to sort first 'N' records of each KEY in a set of records having many records with duplicate keys. Example is shown below::

Input Records:
AAA 1234
AAA 2345
AAA 9878
AAA 6754
BBB 5675
BBB 2346
BBB 2345
CCC 5674
CCC 4325
AAA 3453
BBB 3636

From the above input, I need to sort out first 2 records of each Key (Key = First 3 bytes) and write in out file the combined output

Expected output.
AAA 1234
AAA 2345
BBB 5675
BBB 2346
CCC 5674
CCC 4325

Is there any utility that can be used for the above scenario ? Could any one help me with the solution for the above problem?
It is greatly appreciated, if you provide and solution which can be used in a JCL.

-Ram
gopal0802
 
Posts: 1
Joined: Sun Jun 21, 2009 8:29 am
Has thanked: 0 time
Been thanked: 0 time

Re: Sort first 'N' records for each Key in a group of DUP keys

 

Re: Sort first 'N' records for each Key in a group of DUP keys

Postby skolusu » Mon Jun 22, 2009 8:35 pm

gopal0802,

The following DFSORT/ICETOOL jcl will give you the desired results

//STEP0100 EXEC PGM=ICETOOL                   
//TOOLMSG  DD SYSOUT=*                         
//DFSMSG   DD SYSOUT=*                         
//IN       DD *                               
AAA 1234                                       
AAA 2345                                       
AAA 9878                                       
AAA 6754                                       
BBB 5675                                       
BBB 2346                                       
BBB 2345                                       
CCC 5674                                       
CCC 4325                                       
AAA 3453                                       
BBB 3636                                       
//OUT      DD SYSOUT=*                         
//TOOLIN   DD *                               
  SELECT FROM(IN) TO(OUT) ON(1,3,CH) FIRST(2) 
//*


For more details about selecting the first n records and other new features visit
http://www.ibm.com/systems/support/stor ... /mvs/ugpf/
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post