You can use a DFSORT job like the following to do what you asked for:
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
a |5 | 7
b |7 | 3
c |3 | 6
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTFIL REMOVECC,
TRAILER1=('all |',TOT=(6,2,UFF,M10,LENGTH=2),'|',
TOT=(9,2,UFF,M10,LENGTH=2))
/*
Note that we use the TOT function for the totals, not the COUNT function.
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:
http://www.ibm.com/support/docview.wss? ... g3T7000080