IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Count of group of similar records


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Lijo

New User


Joined: 24 Aug 2008
Posts: 41
Location: Cochin

PostPosted: Wed Sep 24, 2008 3:31 pm
Reply with quote

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
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed Sep 24, 2008 3:41 pm
Reply with quote

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
View user's profile Send private message
Lijo

New User


Joined: 24 Aug 2008
Posts: 41
Location: Cochin

PostPosted: Wed Sep 24, 2008 3:56 pm
Reply with quote

It's working absolutely fine as expected.

Thanks Sambhaji...
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed Sep 24, 2008 4:05 pm
Reply with quote

One correction..
Quote:

sort fields=(1,6,ch)

should be changed to

sort fields=(1,6,ch,a)
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Wed Sep 24, 2008 4:32 pm
Reply with quote

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
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed Sep 24, 2008 5:35 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
Search our Forums:

Back to Top