Retain last of duplicate groups



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

Retain last of duplicate groups

Postby whowillwait4u » Wed Dec 31, 2014 2:59 pm

i need only the latest group if header is repeated.

Input:
---------
Header A1
data1
data2
data3
header A2
data4
header A2
data5
data6
header A2
data7
data8
header A3
data9

Output:
----------
Header A1
data1
data2
data3
header A2
data7
data8
header A3
data9


Could you please help?
whowillwait4u
 
Posts: 15
Joined: Fri Feb 17, 2012 2:07 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Retain last of duplicate groups

 

Re: Retain last of duplicate groups

Postby BillyBoyo » Thu Jan 01, 2015 7:28 am

You can use JOINKEYS with the same DSN for the two input files. In JNF2CNTL, use INCLUDE to only get the headers and use SUM with a dummy count so that you get one record with a count of the number of duplicates.

In JNF1CNTL, use WHEN=GROUP to PUSH the header onto all records for that group, with an ID.

Do the JOINKEYS on the header/summed-value and header/ID. Only write out matches (don't use a JOIN statement, so that you only get matches by default).
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Retain last of duplicate groups

Postby whowillwait4u » Thu Jan 08, 2015 3:16 pm

Thank you. I got the logic. It worked.
whowillwait4u
 
Posts: 15
Joined: Fri Feb 17, 2012 2:07 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Retain last of duplicate groups

Postby BillyBoyo » Thu Jan 08, 2015 3:49 pm

Good work. If you can post your solution, it may help others.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post