Counting duplicated keys in file



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

Counting duplicated keys in file

Postby ottoelflaco » Mon May 13, 2013 6:33 pm

Hi experts!

Anybody know How could I count the duplicated records like the next example?

Input file (key is in the column 1,4):

0001jose
0001jose
0001jose
0002raul
0002raul
0003james


My desired output would be:
0001jose    03
0002raul     02
0003james  01


Counter would be in the end (column 10,2) of each record.
ottoelflaco
 
Posts: 36
Joined: Fri Sep 21, 2012 2:33 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Counting duplicated keys in file

 

Re: Counting duplicated keys in file

Postby dick scherrer » Mon May 13, 2013 7:14 pm

Hello,

Suggest you try SUM FIELDS.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Counting duplicated keys in file

Postby BillyBoyo » Mon May 13, 2013 7:28 pm

Is the data already sorted on the key, as you show?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Counting duplicated keys in file

Postby ottoelflaco » Mon May 13, 2013 7:44 pm

hi, data aren´t sorted,

Hi dick, I have seen this in the forum,



//STEP0001 EXEC PGM=SORT                                                
//SYSOUT   DD SYSOUT=*                                                  
//SORTIN   DD *                                                          
your data                                                
//SYSIN    DD *                                                          
  SORT FIELDS=COPY                                                      
  OUTFIL REMOVECC,NODETAIL,                                              
    SECTIONS=(1,5,                                                      
       TRAILER3=(1,5,COUNT=(M10,LENGTH=3)))          
/*  


syncsort-synctool/topic3859.html

But I don´t understand that, and it don´t work, I continues looking info.

Thank you all
ottoelflaco
 
Posts: 36
Joined: Fri Sep 21, 2012 2:33 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Counting duplicated keys in file

Postby ottoelflaco » Mon May 13, 2013 7:46 pm

hi, data aren´t sorted,

Hi dick, I have seen this in the forum,



//STEP0001 EXEC PGM=SORT                                                
//SYSOUT   DD SYSOUT=*                                                  
//SORTIN   DD *                                                          
your data                                                
//SYSIN    DD *                                                          
  SORT FIELDS=COPY                                                      
  OUTFIL REMOVECC,NODETAIL,                                              
    SECTIONS=(1,5,                                                      
       TRAILER3=(1,5,COUNT=(M10,LENGTH=3)))          
/*  


syncsort-synctool/topic3859.html

But I don´t understand that, and it don´t work, I continues looking info.

Thank you all
ottoelflaco
 
Posts: 36
Joined: Fri Sep 21, 2012 2:33 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Counting duplicated keys in file

Postby dick scherrer » Mon May 13, 2013 10:25 pm

Hello,

To get the summaries you want, sort the data and then use SUM FIELDS.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Counting duplicated keys in file

Postby skolusu » Tue May 14, 2013 3:36 am

ottoelflaco wrote:hi, data aren´t sorted


If your data is not sorted on the key, you need to use SORT FIELDS=(your key you want to count on) instead of SORT FIELDS=COPY

ex:
  SORT FIELDS=(1,4,CH,A)
  OUTFIL REMOVECC,NODETAIL,                                             
    SECTIONS=(1,4,                                                     
       TRAILER3=(1,4,X,COUNT=(M10,LENGTH=3)))         
//*   
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post