Adding the counts of duplicates while keeping the duplicate.

IBM's Sort Product, ICETOOL, ICEMAN and ICEGENER.
Post Reply
Atul Bhosale
New Member
Posts: 7
Joined: Sun Aug 17, 2014 4:45 pm

Adding the counts of duplicates while keeping the duplicate.

Post by Atul Bhosale »

Hi,

I'm struggling with a situation where I want to find records in a file that have duplicate values in one part of the record. I can do this, but I also want to retain all records in the output.

Here is the example:

Input:

Code: Select all

ABCDEF 
ABCDEF 
ABCDEF
ABCDEF
FGHIJK 
FGHIJK 
FGHIJK 
FGHIJK 
outfile:

Code: Select all

ABCDEF 4 
ABCDEF 4
ABCDEF 4 
FGHIJK 4 
FGHIJK 4 
FGHIJK 4 
FGHIJK 4 
I've used this:

Code: Select all

INREC FIELDS=(1,6,9:2X,SEQNUM,8,ZD) 
SORT FIELDS=(1,6,CH,A) 
SUM FIELDS=(11,8,ZD) 
But it's not working as per expectation and am getting this as output:

Code: Select all

ABCDEF 4 
FGHIJK 4 
I actually want to keep the duplicate records, while the above one removes them. How can I do that, please advise me on this.

Thanks
zprogrammer
Global Moderator
Global Moderator
Posts: 588
Joined: Wed Nov 20, 2013 11:53 am
Location: Mars

Re: Adding the counts of duplicates while keeping the duplicate.

Post by zprogrammer »

Have your output of SUM FIELDS and do a JOIN KEYS, Also another option ICETOOL
zprogrammer
Atul Bhosale
New Member
Posts: 7
Joined: Sun Aug 17, 2014 4:45 pm

Re: Adding the counts of duplicates while keeping the duplicate.

Post by Atul Bhosale »

zprogrammer wrote: Have your output of SUM FIELDS and do a JOIN KEYS, Also another option ICETOOL
Have your output of SUM FIELDS, means what do I do?
Chandan Yadav
Website Team
Website Team
Posts: 70
Joined: Wed Jul 31, 2013 10:19 pm

Re: Adding the counts of duplicates while keeping the duplicate.

Post by Chandan Yadav »

Atul Bhosale wrote: Have your output of SUM FIELDS, means what do I do?
What Z programmer mean to say is execute two steps
1. Do the sum fields and get the output as you have mentioned
2. Use join keys to join your input file and o/p from step1, get the desired result

Thanks,
Chandan
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM DFSort, ICETOOL, ICEMAN, ICEGENER.”