Here is a SyncSort for z/OS 1.3 job that will produce the requested output:
//STEP1 EXEC PGM=SORT
//SORTIN DD *
0001
0002
0002
0003
0004
0005
0005
//SORTXDUP DD DSN=&&XDUP,DISP=(NEW,PASS)
//SORTOF01 DD DSN=&&OUT1,DISP=(NEW,PASS)
//SORTOF02 DD DSN=UNIQUE.RECORDS
//SYSOUT DD SYSOUT=*
//SYSIN DD *
INREC OVERLAY=(81:X'F1')
SORT FIELDS=(1,5,CH,A)
DUPKEYS SUM=(81,1,ZD),XDUP
OUTFIL FILES=01,INCLUDE=(81,1,ZD,GT,1)
OUTFIL FILES=02,INCLUDE=(81,1,ZD,EQ,1),BUILD=(1,80)
/*
//STEP2 EXEC PGM=SORT
//SORTIN01 DD DSN=&&XDUP,DISP=SHR
//SORTIN02 DD DSN=&&OUT1,DISP=SHR
//SORTOUT DD DSN=ALLDUPS
//SYSOUT DD SYSOUT=*
//SYSIN DD *
INREC BUILD=(1,80)
MERGE FIELDS=(1,5,CH,A)
/*