Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Is that it for the entire file? If not, show something representative and expected output.
Assuming that is it, you need WHEN=GROUP for 'read' and PUSH the 1,2 for the count to an extension of the record, RECORDS=3. WHEN=GROUP for 'write', PUSH 1,2 to a different place. WHEN=(logical expression) for 'skip' and calculate with 1,2 and the two PUSHed values.
yes, it is entire file ...ok, I can push 1,2 for read and write ... then I can use ifthen skip, but how I can calculate the result from previous records?
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
This is basically your code from the first CNTL file. To cut back down to 80-byte records, you could have used OUTREC BUILD, or OUTFIL BUILD or you can use IFOUTLEN (the most efficient way to do it) which sets the record-length to the value specified. I've cange your BUILD to OVERLAY, and included the RECORDS= I suggested (not particularly give you much for this task, but gets you used to what they can do).
Untested, but should be about there. Make more use of indentation, you'll find things easy to flip around.
Other than choosing ICETOOL rather than SORT you did a fairly good job of implementing what I suggested. This will help you with similar tasks in the future.