I want to sort above two files and write it to File2
in the following layout
It appears from your example that you are NOT sorting - you're just copying Data1 after Data2 and keeping the Header2 and Footer2 records.
You need to show a better example of your actual input records and what you want for output. Give the RECFM and LRECL of the input files. Give the starting position, length and format of all relevant fields.
Is there something in the headers and footers that identify them (e.g. 'H' in position 1 for header and 'T' in position 1 for footer)?
Do you actually want to sort on some field in the data records, or do you just want to copy them in their original order with the Data1 records after the Data2 records?
You can use a DFSORT/ICETOOL job like the following to do what you asked for. I assume by "low values after position 5", you mean X'00' in position 6, and that by "high values after 5th position", you mean X'FF' in position 6. If not, change the OMIT conditions appropriately. //OUT must be a MOD data set or SYSOUT=*.