try this snippet. this may give you the perfect solution.
//STEP1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SORTIN DD *
W |Z|111|
W 6 5 4 |Z|111|
W9 |Z|111|
W96653400 |Z|111|
W966 34000|Z|111|
W9665 44 |Z|111|
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=(2,9,CH,EQ,C' '),FINDREP=(IN=C' ',OUT=C'',
STARTPOS=2,ENDPOS=10)),
IFTHEN=(WHEN=(3,8,CH,EQ,C' '),FINDREP=(IN=C' ',OUT=C'',
STARTPOS=3,ENDPOS=10)),
IFTHEN=(WHEN=(4,7,CH,EQ,C' '),FINDREP=(IN=C' ',OUT=C'',
STARTPOS=4,ENDPOS=10)),
IFTHEN=(WHEN=(5,6,CH,EQ,C' '),FINDREP=(IN=C' ',OUT=C'',
STARTPOS=5,ENDPOS=10)),
IFTHEN=(WHEN=(6,5,CH,EQ,C' '),FINDREP=(IN=C' ',OUT=C'',
STARTPOS=6,ENDPOS=10)),
IFTHEN=(WHEN=(7,4,CH,EQ,C' '),FINDREP=(IN=C' ',OUT=C'',
STARTPOS=7,ENDPOS=10)),
IFTHEN=(WHEN=(8,3,CH,EQ,C' '),FINDREP=(IN=C' ',OUT=C'',
STARTPOS=8,ENDPOS=10)),
IFTHEN=(WHEN=(9,2,CH,EQ,C' '),FINDREP=(IN=C' ',OUT=C'',
STARTPOS=9,ENDPOS=10)),
IFTHEN=(WHEN=(10,1,CH,EQ,C' '),FINDREP=(IN=C' ',OUT=C'',
STARTPOS=10,ENDPOS=10))