Based on your decription, you could use a DFSORT job like the following to do what you asked for. If that's not what you want, then you need to do a better job of describing the situation.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration => DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort