Page 1 of 1

Counting duplicated keys in file

PostPosted: Mon May 13, 2013 6:33 pm
by ottoelflaco
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.

Re: Counting duplicated keys in file

PostPosted: Mon May 13, 2013 7:14 pm
by dick scherrer
Hello,

Suggest you try SUM FIELDS.

Re: Counting duplicated keys in file

PostPosted: Mon May 13, 2013 7:28 pm
by BillyBoyo
Is the data already sorted on the key, as you show?

Re: Counting duplicated keys in file

PostPosted: Mon May 13, 2013 7:44 pm
by ottoelflaco
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

Re: Counting duplicated keys in file

PostPosted: Mon May 13, 2013 7:46 pm
by ottoelflaco
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

Re: Counting duplicated keys in file

PostPosted: Mon May 13, 2013 10:25 pm
by dick scherrer
Hello,

To get the summaries you want, sort the data and then use SUM FIELDS.

Re: Counting duplicated keys in file

PostPosted: Tue May 14, 2013 3:36 am
by skolusu
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)))         
//*