Hello johnH,
You can try below code..
//STEP1A EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD *
Y0812 AA1
0412 AA2
0712 AAC
Y0212 AA3
Y0712 AAA
0112 AA4
0612 BB1
//SORTOUT DD SYSOUT=*
INREC BUILD=(01,10,81:04,02,83:02,02)
SORT FIELDS=COPY
OUTFIL OUTREC=(1,10),INCLUDE=(1,1,CH,EQ,C'Y',AND,
81,4,Y2T,EQ,Y'DATE2'-1)
Output will be :-