There are specific compare utilities designed for doing comparisons. But since you're asking in the DFSORT Forum, I assume you're looking for a DFSORT solution. If so, you need to give more details. Show an example of the records in each input file (relevant fields only) and the expected output records. Describe the "rules" for getting from input to output. Give the RECFM and LRECL of the input files. Give the starting position, length and format of the relevant fields.