Count of Records row wise.



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

Count of Records row wise.

Postby Sushmita V » Thu Jan 19, 2012 9:32 pm

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
Sushmita V
 
Posts: 12
Joined: Thu Jan 19, 2012 9:26 pm
Location: Chennai, India
Has thanked: 0 time
Been thanked: 0 time

Re: Count of Records row wise.

Postby skolusu » Thu Jan 19, 2012 10:08 pm

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
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

Re: Count of Records row wise.

Postby Sushmita V » Fri Jan 20, 2012 10:17 am

Hi skolusu,

It worked! Thanks much.

With regards,
Sushmita V
Sushmita V
 
Posts: 12
Joined: Thu Jan 19, 2012 9:26 pm
Location: Chennai, India
Has thanked: 0 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post