Example
PERFORM procedure-name-1 THROUGH procedure-name-2
VARYING identifier-2 FROM identifier-3
BY identifier-4 UNTIL condition-1
AFTER identifier-5 FROM identifier-6
BY identifier-7 UNTIL condition-2
- identifier-2 and identifier-5 are set to their initial values, identifier-3 and identifier-6, respectively.
- condition-1 is evaluated as follows:
- If it is false, steps 3 through 7 are executed.
- If it is true, control passes directly to the statement following the PERFORM statement.
- condition-2 is evaluated as follows:
- If it is false, steps 4 through 6 are executed.
- If it is true, identifier-2 is augmented by identifier-4, identifier-5 is set to the current value of identifier-6, and step 2 is repeated.
- procedure-name-1 and everything up to and including procedure-name-2 (if specified) are executed once.
- identifier-5 is augmented by identifier-7.
- Steps 3 through 5 are repeated until condition-2 is true.
- Steps 2 through 6 are repeated until condition-1 is true.
At the end of PERFORM statement execution:
- identifier-5 contains the current value of identifier-6.
- identifier-2 has a value that exceeds the last-used setting by the increment/decrement value (unless condition-1 was true at the beginning of PERFORM statement execution, in which case, identifier-2 contains the current value of identifier-3).
Figure 1 illustrates the logic of the PERFORM statement when two identifiers are varied with TEST BEFORE. Figure 2 illustrates the logic of the PERFORM statement when two identifiers are varied with TEST AFTER.
Figure 1. Varying Two Identifiers—with TEST BEFORE

The previous figure assumes that identifier-5 and identifier-2 are not related. If one is dependent on the other (through subscripting, for example), the results may be predictable but generally undesirable.
Figure 2. Varying Two Identifiers—with TEST AFTER
