View previous topic :: View next topic
|
Author |
Message |
Lijo
New User
Joined: 24 Aug 2008 Posts: 41 Location: Cochin
|
|
|
|
Hi,
I've a requirement to count group of similar records...
My input file has:
0100040000234560
0100040000234560
0100050000234556
6006570011587234
6006571158723401
6006571158723402
Output should be:
010004 - 2
010005 - 1
600657 - 3
Count should be taken based on first six characters (1,6,CH).
Can someone help me? |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
use sort card as below
Code: |
//sysin dd *
inrec fields=(1,6,7:c'001')
sort fields=(1,6,ch)
sum fields=(7,3,zd)
outrec fields(1,6,7:c'-',7,3)
/*
|
|
|
Back to top |
|
|
Lijo
New User
Joined: 24 Aug 2008 Posts: 41 Location: Cochin
|
|
|
|
It's working absolutely fine as expected.
Thanks Sambhaji... |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
One correction..
Quote: |
sort fields=(1,6,ch)
|
should be changed to
sort fields=(1,6,ch,a) |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Lijo,
If your input records are already in sorted order of the key, you can omit the INREC pass like this.
Code: |
//SYSIN DD *
OPTION COPY
OUTFIL REMOVECC,NODETAIL,
SECTIONS=(1,6,TRAILER3=(1,6,C'-',COUNT=(M10,LENGTH=5))) |
Code: |
010004- 2
010005- 1
600657- 3 |
|
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Quote: |
Thanks Sambhaji...
|
You are welcome..
One more thing should be kept in mind here is prefixing enough number of zeros so that count (sum) will not overflow else it will fail. |
|
Back to top |
|
|
|