I'd like to merge all of these in one pass if possible. From looking at the manual (DFSORT Application Programming Guide 3rd Ed.) it seems I needs to use a splice and WITHEACH (there is an example of something which looks like what I'm suggesting at the top of pg. 583), but I'm not sure how I need to do this.
Please show a better example of the records in your input files (relevant fields only), including the case that doesn't work, and the expected output records. Give the RECFM and LRECL of the input files. Give the starting position, length and format of each relevant field in each input file.