Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Code:
INREC FIELDS=(1,40,X'0000001C')
SORT FIELDS=(5,3,PD,A)
SUM FIELDS=(41,4,PD)
OUTREC FIELDS=(1:5,3,PD,M0,
12:41,4,PD,M0)
INREC statement - copies input positions 1-40 and adds a PD value of 1 in positions 41-44. The PD value of 1 is being used as a counter.
SORT - sorts on the key which is the PD value in positions 5-8.
SUM - for each key value, keeps one record and adds up the counter to get the count of records for that key. So you end up with one record per key containing the count of records with that key.
OUTREC - converts the key value to a printable value in the form IIIITS with leading zeros suppressed and a trailing sign of blank or - (for example, '1234 ' or ' 1-'. Converts the counter to a printable value in the same form.
For example, if the input records had:
Code:
Key (PD)
-1234
-1234
+1234
-1234
+1234
The output would be
Code:
Key Count
1234- 3
1234 2
If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from: