Adding the counts of duplicates while keeping the duplicate.

IBM's Sort Product, ICETOOL, ICEMAN and ICEGENER.
Previous topicNext topic

Topic Author
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 » Tue May 16, 2017 1:31 pm

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: 605
Joined: Wed Nov 20, 2013 11:53 am
Location: Mars
Zodiac: Libra

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

Post by zprogrammer » Tue May 16, 2017 10:13 pm

Have your output of SUM FIELDS and do a JOIN KEYS, Also another option ICETOOL


zprogrammer


Topic Author
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 » Thu May 18, 2017 1:51 pm

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: 69
Joined: Wed Jul 31, 2013 10:19 pm
Zodiac: Libra

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

Post by Chandan Yadav » Thu Jun 01, 2017 1:50 pm

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



Previous topicNext topic

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