You show data already in sequence, so there is no need to sort the data itself, which makes SUM FIELDS= with SORT a poor solution if anyone suggests it (plus code for the formatting). MERGE with a single input file and SUM FIELDS= would be better, but still require the...
For a fixed-position start of the trigger: OPTION COPY INREC IFTHEN=(WHEN=GROUP, BEGIN=(1,5,CH,EQ,C'start'), PUSH=(171:ID=1)) OUTFIL OMIT=(171,1,CH,EQ,C' '), BUILD=(1,170) For a variable-position, unique, trigger: OPTION COPY INREC IFTHEN=(WHEN=GROUP, BEGIN=(1,170,SS,EQ,C'start'), PUSH=(171:ID=1)) OUTFIL OMIT=(171,1,CH,EQ,C' '), BUILD=(1,170) WHEN=GROUP gives you PUSH, which will put data from the current record, or a group-number (ID) or number...