Page 1 of 1

Retain last of duplicate groups

PostPosted: Wed Dec 31, 2014 2:59 pm
by whowillwait4u
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?

Re: Retain last of duplicate groups

PostPosted: Thu Jan 01, 2015 7:28 am
by BillyBoyo
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).

Re: Retain last of duplicate groups

PostPosted: Thu Jan 08, 2015 3:16 pm
by whowillwait4u
Thank you. I got the logic. It worked.

Re: Retain last of duplicate groups

PostPosted: Thu Jan 08, 2015 3:49 pm
by BillyBoyo
Good work. If you can post your solution, it may help others.