Posted: Fri Aug 19, 2005 2:32 pm Post subject: Need counts
Hi,
I am using Syncsort. My file length is 80 bytes and FB.
It has two fields. Field1 has one byte length and has values either A or B.
Field2 has 4 bytes length and could be any value. My file is sorted based
field2 and field1.
input
Code:
----+----1-
***********
A 0011
A 0011
A 0011
B 0011
B 0011
A 0022
A 0022
B 0022
A 0123
A 0123
A 0123
B 0123
B 0123
Now I need the counts of A and B for each value in field2.
The o/p shld be
Code:
0011 - A Count is 3 and B count is 2
0022 - A Count is 2 and B count is 1
0123 - A Count is 3 and B count is 2
Joined: 26 Nov 2002 Posts: 12369 Topics: 75 Location: San Jose
Posted: Fri Aug 19, 2005 4:19 pm Post subject:
Robo,
The following JCL will give you the desired results.
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
A 0011
A 0011
A 0011
B 0011
B 0011
A 0022
A 0022
B 0022
A 0123
A 0123
A 0123
B 0123
B 0123
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(3,4,CH,A)
OUTREC FIELDS=(1,6,
7:1,1,CHANGE=(1,C'A',C'1'),NOMATCH=(C'0'),
8:1,1,CHANGE=(1,C'B',C'1'),NOMATCH=(C'0'),
80:X)
OUTFIL REMOVECC,NODETAIL,
SECTIONS=(3,4,
TRAILER3=(3,4,
C' A COUNT IS ',
TOT=(7,1,ZD,EDIT=(IIIIIIIT)),
C' AND B COUNT IS ',
TOT=(8,1,ZD,EDIT=(IIIIIIIT))))
/*
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum