Page 1 of 1

Count and write occurences

PostPosted: Sat Sep 19, 2009 2:07 am
by ranga_subham
Hi, Input file is FB and LRECL is 80 only.

Input File:
----+----1----+----2----+----3----+----4
    1A1ZJ57763A 101
49D70FAIFE0   A 201
    1F2ZJ57B606 101
XKFX3HP0IBB   6 201
    1O2ZJ57B496 101
BBJL9KG7K34   6 201
    1X2ZJ57B486 101
BBJL9KG7K34   6 201
    1B1ZJ57763A 101
49D70FAIFE0   A 201
    1C1TJ57763A 101
S9D70FAIFE0   A 201
    1D2ZJ57V606 101
TKFX3HP0IBB   6 201


Output: I want to count the total number of records for each variety of value appearing at 14th position and write like below:
STATS:
TOTAL NUMBER OF RECS FOR TYPE '0': 00002
TOTAL NUMBER OF RECS FOR TYPE '3': 00003
TOTAL NUMBER OF RECS FOR TYPE '8': 00001
TOTAL NUMBER OF RECS FOR TYPE '9': 00001


Note: The values appearing at 14th position range from '0' to '9'.

Please help.

Thanks.

Re: Count and write occurences

PostPosted: Sat Sep 19, 2009 2:42 am
by dick scherrer
Hello,

What about the records with spaces in 14th position?

Re: Count and write occurences

PostPosted: Sat Sep 19, 2009 9:20 am
by ranga_subham
Hi,

That situation never arises.....

Thx.

Re: Count and write occurences

PostPosted: Mon Sep 21, 2009 2:33 am
by dick scherrer
Hello,

I'm proabaly just having a really bad day. . .

The posted sample data has a space in pos 14 of all of the alternating records :?
All of the records with "201" in pos 17-19 have a space in pos 14. . .
Don't they?

As i mentioned, i am probably just missing something . . .

Re: Count and write occurences

PostPosted: Mon Sep 21, 2009 10:48 am
by lal
Hi,
The following code should give you the desired results...
As Dick Scherrer says there are indeed spaces in 14th column

//SYSIN    DD *                                                     
  SORT FIELDS=(14,1,CH,A)                                           
  OUTFIL REMOVECC,NODETAIL,                                         
  SECTIONS=(14,1,                                                   
  TRAILER3=(1:'TOTAL NUMBER OF RECS FOR TYPE ','''',14,1,'''',':', 
            COUNT))                                                 
//*                                                                 


Thanks,
lal