Data editing > Flow control > Loops
 
Loops
Quick reference
To define a set of repetitive statements, type:
do label_number int_variable=value_list
statements
label_number statement
More information
Loops enable the same set of basic statements to be executed over and over again on a changing series of numbers, columns or codes. They can reduce the work involved in checking data. The statement which introduces a loop is do which is formatted as follows:
the word do
a label number identifying the last statement in the loop
an integer variable (for numbers or columns) or a letter (for codes) whose value is to be used by the statements in the loop
an equals sign
a list of whole numbers, integer variables or codes which are the values the integer variable or letter is to take.
Terminate loops with any statement other than go to, stop, return, another do or an if containing any of these words. The terminating statement identifies the end of the loop and sends the program back to the start of the loop. Go to and return send the record elsewhere, stop terminates the run and another do indicates the start of another loop. The statement most often used to terminate a loop is the continue. Any statement that terminates a loop must be preceded by a label number. For information about the return statement, see Jumping to the tabulation section.
Thus, the usual format of a loop is:
do label.number int.var = value list
- - statements to be executed - -
label.number statement
See
do with individually specified numeric values
do with numeric ranges
do with codes
Nested loops
Routing with loops
See also
Flow control