Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Count the number of occurances in a input file using Sort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
anandkumarrn

New User


Joined: 06 Feb 2009
Posts: 23
Location: India

PostPosted: Wed Apr 08, 2009 11:11 pm    Post subject: Count the number of occurances in a input file using Sort
Reply with quote

I have a requirement, i have an input file as below

001 11 kajdkasd
002 11 dlksldakas
005 11 sdaslkdl
003 11 jsdkjfksdj
004 02 lkdlas
006 02 ldkasldk
008 13 djksdksd

here I need to get the output as below.

in count 11 : 4
count 02: 2
count 13:1

Regards,
Anand
Back to top
View user's profile Send private message

CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Wed Apr 08, 2009 11:18 pm    Post subject:
Reply with quote

Is Count the amount of records for everycode close?
Back to top
View user's profile Send private message
anandkumarrn

New User


Joined: 06 Feb 2009
Posts: 23
Location: India

PostPosted: Thu Apr 09, 2009 12:03 am    Post subject:
Reply with quote

Hi CICS Guy,

Thanks for your timely help,

But i am facing a problem, the output count is not equal to the input records,
say i have a input file with 111964 and in output it gives 111979 records.
so there is a mismatch between these two counts

i am using the below code in my sysin

OCCURS FROM(INFILE) LIST(OUFILE) NOHEADER ON(27,2,CH) ON(VALCNT)

please give us a soln.

Regards,
Anand
Back to top
View user's profile Send private message
anandkumarrn

New User


Joined: 06 Feb 2009
Posts: 23
Location: India

PostPosted: Thu Apr 09, 2009 12:09 am    Post subject:
Reply with quote

anandkumarrn wrote:
Hi CICS Guy,

Thanks for your timely help,

But i am facing a problem, the output count is not equal to the input records,
say i have a input file with 111964 and in output it gives 111979 records.
so there is a mismatch between these two counts

i am using the below code in my sysin

OCCURS FROM(INFILE) LIST(OUFILE) NOHEADER ON(27,2,CH) ON(VALCNT)

please give us a soln.

Regards,
Anand



I missed to mention
i am using a input file which is Variable format.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Thu Apr 09, 2009 12:25 am    Post subject:
Reply with quote

With the NOHEADER, I wonder where the 15 extra lines come from.
Have you looked at the first portion and the last portion of the output?
Back to top
View user's profile Send private message
anandkumarrn

New User


Joined: 06 Feb 2009
Posts: 23
Location: India

PostPosted: Thu Apr 09, 2009 12:37 am    Post subject:
Reply with quote

CICS Guy wrote:
With the NOHEADER, I wonder where the 15 extra lines come from.
Have you looked at the first portion and the last portion of the output?


yes, based on that only i identified the count value
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Thu Apr 09, 2009 12:40 am    Post subject:
Reply with quote

anandkumarrn wrote:
yes, based on that only i identified the count value
I don't quite understand.....
What does the sort message look like, could you post it here?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Apr 09, 2009 4:09 am    Post subject:
Reply with quote

Anand,

It's not clear what you mean by the "output count". The count of records in the LIST data set would NOT match the count of input records unless you had NO duplicates. You only get one line per duplicate, so if you had two records with the same key, the input count would be 2, but the output count would be 1.

The sum of the ON(VALCNT) occurrences would equal the number of input records.

Since you said your records are VB, I assume your use of 27 for the starting position includes the RDW in positions 1-4. If not, you need to use 31 as the starting position, but the counts would add up either way.

For example, if I have these input records in INFILE (rrrr for the RDW):

Code:

rrrr001                   11 KAJDKASD
rrrr002                   11 DLKSLDAKAS
rrrr005                   11 SDASLKDL
rrrr003                   11 JSDKJFKSDJ
rrrr004                   02 LKDLAS
rrrr006                   02 LDKASLDK
rrrr008                   13 DJKSDKSD


and I use your OCCURS operator, I get this output in OUFILE:

Code:

02                     000000000000002     
11                     000000000000004     
13                     000000000000001     


The input count is 7, but the count of records in the LIST data set is 3. However, the total of the VALCNT counts is 7.

If I look in TOOLMSG, I see this message which tells me the total number of input records processed is also 7.

Code:

ICE628I 0 RECORD COUNT:  000000000000007     


So the total of the VALCNT counts matches the input record count.
The count of records in the LIST data set does not match the input record count, but that's expected since there are duplicate records.

Are you saying that the value in ICE628I that does not match the total of the VALCNT values, or are you saying that the value in ICE628I does not match the actual number of input records, or what?

If you really think there's a mismatch, show the //TOOLMSG and //DFSMSG messages and indicate what you think the mismatched counts are.
Back to top
View user's profile Send private message
anandkumarrn

New User


Joined: 06 Feb 2009
Posts: 23
Location: India

PostPosted: Tue Apr 14, 2009 1:18 pm    Post subject: Frank,
Reply with quote

Hi Frank,
i would say my VALCNT and the input records doesn't match,
that is my input records say 1,00,000(1 lakh) and my output count(VALCNT) shows 1,00,015(1 lakh 15 records). so there is a mismatch between the input and the output VALCNT, i am getting this type of error if i have large number of records, i am getting exact count if i have less number of records in my input file.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Tue Apr 14, 2009 8:47 pm    Post subject:
Reply with quote

I can't help you without knowing exactly what you're doing. I don't know what your JCL looks like (for all I know, you could be using concatenation with referback and losing records due to a system restriction on doing that) or what messages you're getting.

I need to see the JES, //TOOLMSG and //DFSMSG output for the job you think has the mismatch. You can send it to me offline (yaeger@us.ibm.com) preferably as an attached text file.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to change 'K' or 'M' use Sort vice_versa DFSORT/ICETOOL 5 Thu May 18, 2017 7:11 am
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us