This got a random poke, so...
Deuian I think was on the right lines, but left some complication and for user change didn't use the correct positions or type of output file, so would have been too much typing to apply to the situation...
OPTION COPY
INCLUDE COND=(38,8,CH,EQ,C'AMSAM00')
OUTFIL FILES=02,
INCLUDE=(390,1,CH,EQ,C'Y'),
BUILD=(1,4,382,8)
OUTFIL FILES=03,
INCLUDE=(545,4,CH,NE,C'0000',
AND,390,1,CH,NE,C'Y'),
BUILD=(1,4,C'013,',545,4)
OUTFIL FILES=01,SAVE,
BUILD=(1,4,366,8)
This presumes that SORTOUT will not be needed (it would just be a copy of the input file).
All the AMSAM00 records are INCLUDED, everything else (which is unwanted for the OUTFILs) is ignored.
OUTFIL 02 gets all the 'Y's.
OUTFIL 03 gets all the not 0000s which are not 'Y'
OUTFIL 01, moved to make it easier to follow, gets all the records which are not selected on another OUTFIL (by using SAVE).
All of the data which passes the INCLUDE will be on one of the three OUTFILs, and only one.
I have used OPTION COPY for clarity. SORT FIELDS=(... logically appears after the INCLUDE (wherever you code it) and by using OPTION COPY it is clear, up front, and in a logical place, that it is a COPY operation.
I have taken out the "columns" from the BUILDs (those numbers followed by a colon). If the data is going into that column automatically (which it is), then using the columns only creates work, introduces a new possibility of error, and makes the Sort Control Cards more difficult to maintain.
The question is unclear, so this is just a guess at what was wanted.
There was mention of OUTREC.
From the context, this is OUTREC on OUTFIL. There is a separate OUTREC statement. To avoid confusion (due to the "overloading" of OUTREC), don't use OUTREC on OUTFIL, which is for "backwards compatability", use the modern BUILD instead, which is entirely equivalent.
BUILD exists on INREC, OUTREC and OUTFIL, separately and as part of an IFTHEN. OUTREC as equivalent of BUILD is only on OUTFIL.
On INREC and OUTREC, FIELDS also has the "overloading" for the same reason (the backwards thing).
Don't use INREC FIELDS=, or OUTREC FIELDS= or OUTFIL OUTREC=, use BUILD in their place.