LOOP-END LOOP
The LOOP-END LOOP
structure performs repeated transformations
specified by the commands within the loop until they reach a specified cutoff. The cutoff can be
specified by an indexing clause on the LOOP
command, an IF
clause
on the END LOOP
command, or a BREAK
command within the loop
structure (see BREAK
).
LOOP [varname=n TO m [BY {1**}]] [IF [(]logical expression[)]]
{n }
transformation commands
END LOOP [IF [(]logical expression[)]]
**Default if the keyword is omitted.
This command does not read the active dataset. It is stored, pending execution with the next command that reads the dataset. See the topic Command Order for more information.
Examples
SET MXLOOPS=10. /*Maximum number of loops allowed
LOOP. /*Loop with no limit other than MXLOOPS
COMPUTE X=X+1.
END LOOP.
LOOP #I=1 TO 5. /*Loop five times
COMPUTE X=X+1.
END LOOP.