An OUTPUT PROCEDURE is also useful when we want to alter the structure of the records written to the sorted file.
In the first example program below, we use an OUTPUT PROCEDURE to summarize the sorted records.