View previous topic :: View next topic
|
Author |
Message |
pshongal
New User
Joined: 14 Jun 2012 Posts: 96 Location: India
|
|
|
|
Hi All,
I have a requirement to limit number of duplicate records in a file.
For e.g:
Below is the record pattern
Code: |
AAA
AAA
BBB
BBB
BBB
BBB
CCC
CCC
CCC
DDD
|
Requirement is to have max 2 duplicate records. So my o/p should be
Code: |
AAA
AAA
BBB
BBB
CCC
CCC
DDD
|
Thanks. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
tell us what sort product You will be using.
look at the messages
WER... ==> SYNCSORT
ICE... ==> IBM DFSORT
and the topic will be moved to the proper section |
|
Back to top |
|
|
pshongal
New User
Joined: 14 Jun 2012 Posts: 96 Location: India
|
|
|
|
We use SYNCSORT |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Use WHEN=GROUP |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Assuming your data is in key order, extend record temporarily with a sequence number, with RESTART= for the key, and out OUTFIL with INCLLUDE=/OMIT= to do the limiting, with BUILD to drop off the extension.
The same could be achieved with WHEN=GROUP, but if the key is on each record, in the same position, then it is better to use the plain sequence number. |
|
Back to top |
|
|
pshongal
New User
Joined: 14 Jun 2012 Posts: 96 Location: India
|
|
|
|
Hi Bill,
Yes, its in sorted order and key is always in same position. |
|
Back to top |
|
|
pshongal
New User
Joined: 14 Jun 2012 Posts: 96 Location: India
|
|
|
|
Thanks Bill & Pandora for your suggestion.
I used sequence number technique. It works. Thanks a lot |
|
Back to top |
|
|
|