Iterative DO loop

Use the iterative DO to increment or decrement a loop counter. The loop is processed for each possible value of the variable within the limits specified. By default, the value is increased by one each time; you can modify this setting with the BY keyword.

DO <variable> = <start> TO <end> [BY <increment>] [FOR <limit>]

where:
<variable>
Name of the variable to be incremented or decremented. Do not include the prefix variable.
<start>
Starting value of the variable. Must be an integer.
<end>
Ending value of the variable. Must be an integer.
<increment>
Value by which the variable is to be incremented or decremented. Must be a positive or negative integer. The default is 1.
<limit>
The maximum number of times that the loop is to be run. Must be an integer. The default is the absolute difference between <start> and <end> + 1.
For example:
DISPLAY “Testing... Testing”
DO X = 1 TO 3
   DISPLAY !X
END

Use the ITERATE command at any point in the block to start the next iteration of the currently active loop from the DO statement again. Use the LEAVE command to exit the currently active loop and resume processing following the corresponding END statement.

The ITERATE and LEAVE commands can be used only to exit the currently active block.