Page 1 of 1

Count of Records row wise.

PostPosted: Thu Jan 19, 2012 9:32 pm
by Sushmita V
Can u help me in writing a SORT card which will count the number of similar records clubbed to sum:

My Input file is:

2013-10-01 00:00:00|ABC |-000000100.15
2013-10-01 00:00:00|ABC |+000000200.15
2013-11-01 00:00:00|DEF |+000000200.15
2013-11-01 00:00:00|DEF |+000000100.15
2013-11-02 00:00:00|XYZ |+000000250.15
2013-11-02 00:00:00|XYZ |+000000400.15



I need an output which will do the following:

2013-10-01 00:00:00|ABC |+000000100.00|2
2013-11-01 00:00:00|DEF |+000000300.30|2
2013-11-02 00:00:00|XYZ |+000000650.30|2

Here, 2 records for ABC from input file were added and so that count is displayed after each unique record.

Can I have the SORT card for getting the same?

Thanks much!
With Regards,
Sushmita V

Re: Count of Records row wise.

PostPosted: Thu Jan 19, 2012 10:08 pm
by skolusu
sushmita V,

Assuming that your data is already sorted on the key (abc, def, xyz...) the following DFSORT JCL will give you the desired results

//STEP0100 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD *                                                     
----+----1----+----2----+----3----+----4----+----5----+----6----+---
2013-10-01 00:00:00|ABC |-000000100.15                             
2013-10-01 00:00:00|ABC |+000000200.15                             
2013-11-01 00:00:00|DEF |+000000200.15                             
2013-11-01 00:00:00|DEF |+000000100.15                             
2013-11-02 00:00:00|XYZ |+000000250.15                             
2013-11-02 00:00:00|XYZ |+000000400.15                             
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                     
  SORT FIELDS=COPY                                                 
  OUTFIL REMOVECC,NODETAIL,                                         
  SECTIONS=(21,3,                                                   
  TRAILER3=(1,25,TOT=(26,13,SFF,EDIT=(STTTTTTTTT.TT),SIGNS=(+,-)), 
            '|',COUNT=(M11,LENGTH=2)))                             
//*


This will produce
2013-10-01 00:00:00|ABC |+000000100.00|02
2013-11-01 00:00:00|DEF |+000000300.30|02
2013-11-02 00:00:00|XYZ |+000000650.30|02

Re: Count of Records row wise.

PostPosted: Fri Jan 20, 2012 10:17 am
by Sushmita V
Hi skolusu,

It worked! Thanks much.

With regards,
Sushmita V