OK, so the first thing you will need is a dummy file header (assuming you don't have file headers).
You need a simple COPY step, which takes a single record from one of you (presumed identical DCB) files, and uses OVERLAY to mark it as the dummy header.
OPTION COPY,STOPAFT=1
INREC OVERLAY=(1:C'HEADER')
You either run this each time, or as a once-of, initially and any time the RECFM or LRECL of the file changes in the future.
Then into your main SORT step, you concatenate the dummy header, prior to each of your input files.
//SORTIN DD DSN=dummy-header
// DD DSN=yourfile1
// DD DSN=dummy-header
// DD DSN=yourfile2
// DD DSN=dummy-header
// DD DSN=yourfile3
// DD DSN=dummy-header
// DD DSN=yourfile4
Then you use WHEN=GROUP to identify the header, and PUSH an ID to temporary extension to the record.
INREC IFTHEN=(WHEN=GROUP,
BEGIN=(1,6,CH,EQ,C'HEADER),
PUSH=(81:ID=1))
This will mark every record (including the header) with a 1 in position 81 for the first file, 2 for the second, etc.
Then you can SORT your data on the key, and then on the extended ID, giving you this:
HEADER1
HEADER2
HEADER3
HEADER4
AAA 1
AAA 2
AAA 3
AAA 4
BBB 2
CCC 1
CCC 3
DDD 1
DDD 2
DDD 3
DDD 4
Then in OUTREC you need WHEN=GROUP with KEYBEGIN for your key, and PUSH SEQ=1 to another extended byte.
Continuing in OUTREC, you have three WHEN=GROUP which test for the extended ID being 1 then 2 then 3. You PUSH the information that you need from that particular record into an extended location (one for each file). You use RECORDS=4, RECORDS=3 and RECORDS=2 in the WHEN=GROUP.
The fourth record of each group (the extended SEQ = 4) is the one you want, and it will contain all the data you need.
In OUTFIL, use INCLUDE= to select the 4s only (and to ignore the HEADER record which happens to be number four).
Then use BUILD to do your final formatting.