Product Site

A.5. COUNTER Phrase

The COUNTER phrase may be used on repetitive DO or LOOP instructions to specify a ctr variable that provides a count value for each repetition. ctr starts with 1 and increases by 1 for each repetition. After the loop finishes, ctr will have the count value of the last repetition, or, if the loop had zero repetitions, ctr will be 0.
Example A.11. Controlled DO loop with COUNTER
do counter ct x = -0.3 to 0.4 by 0.2
  say ct x
end
/* Displays: 1 -0.3, 2 -0.1, 3 0.1, 4 0.3 */