The PERFORM statement transfers control explicitly to one or more procedures and implicitly returns control to the next executable statement after execution of the specified procedures is completed.
The PERFORM statement is:
An in-line PERFORM must be delimited by the END-PERFORM phrase.
The in-line and out-of-line formats cannot be combined. For example, if procedure-name-1 is specified, imperative statements and the END-PERFORM phrase must not be specified.
The PERFORM statement formats are:
The procedures referenced in the basic PERFORM statement are executed once, and control then passes to the next executable statement following the PERFORM statement.
Note: A PERFORM statement must not cause itself to be executed. A recursive PERFORM statement can cause unpredictable results.
When both procedure-name-1 and procedure-name-2 are specified, if either is a procedure-name in a declarative procedure, both must be procedure-names in the same declarative procedure.
If procedure-name-1 is specified, imperative-statement-1 and the END-PERFORM phrase must not be specified.
If procedure-name-1 is omitted, imperative-statement-1 and the END-PERFORM phrase must be specified.
An in-line PERFORM statement functions according to the same general rules as an otherwise identical out-of-line PERFORM statement, except that statements contained within the in-line PERFORM are executed in place of the statements contained within the range of procedure-name-1 (through procedure-name-2, if specified). Unless specifically qualified by the word in-line or the word out-of-line, all the rules that apply to the out-of-line PERFORM statement also apply to the in-line PERFORM.
Whenever an out-of-line PERFORM statement is executed, control is transferred to the first statement of the procedure named procedure-name-1. Control is always returned to the statement following the PERFORM statement. The point from which this control is returned is determined as follows:
The only necessary relationship between procedure-name-1 and procedure-name-2 is that a consecutive sequence of operations is executed, beginning at the procedure named by procedure-name-1 and ending with the execution of the procedure named by procedure-name-2.
PERFORM statements can be specified within the performed procedure. If there are two or more logical paths to the return point, then procedure-name-2 can name a paragraph that consists only of an EXIT statement; all the paths to the return point must then lead to this paragraph.
When the performed procedures include another PERFORM statement, the sequence of procedures associated with the embedded PERFORM statement must be totally included in or totally excluded from the performed procedures of the first PERFORM statement. That is, an active PERFORM statement whose execution point begins within the range of performed procedures of another active PERFORM statement must not allow control to pass through the exit point of the other active PERFORM statement. However, two or more active PERFORM statements can have a common exit.
The following figure illustrates valid sequences of execution for PERFORM statements.

When control passes to the sequence of procedures by means other than a PERFORM statement, control passes through the exit point to the next executable statement, as if no PERFORM statement referred to these procedures.
Delimits the scope of the in-line PERFORM statement. Execution of an in-line PERFORM is completed after the last statement contained within it has been executed.
The procedures referred to in the TIMES phrase PERFORM statement are executed the number of times specified by the value in identifier-1 or integer-1. Control then passes to the next executable statement following the PERFORM statement.
If procedure-name-1 is specified, imperative-statement-1 and the END-PERFORM phrase must not be specified.
If identifier-1 is zero or a negative number at the time the PERFORM statement is initiated, control passes to the statement following the PERFORM statement.
After the PERFORM statement has been initiated, any change to identifier-1 has no effect in varying the number of times the procedures are initiated.
In the UNTIL phrase format, the procedures referred to are performed until the condition specified by the UNTIL phrase is true. Control is then passed to the next executable statement following the PERFORM statement.
If procedure-name-1 is specified, imperative-statement-1 and the END-PERFORM phrase must not be specified.
Any subscripting associated with the operands specified in condition-1 is evaluated each time the condition is tested.
If the TEST BEFORE phrase is specified or assumed, the condition is tested before any statements are executed (corresponds to DO WHILE).
If the TEST AFTER phrase is specified, the statements to be performed are executed at least once before the condition is tested (corresponds to DO UNTIL).
In either case, if the condition is true, control is transferred to the next executable statement following the end of the PERFORM statement. If neither the TEST BEFORE nor the TEST AFTER phrase is specified, the TEST BEFORE phrase is assumed.
The VARYING phrase increases or decreases the value of one or more identifiers or index-names, according to certain rules. (See Varying phrase rules.)
The format-4 VARYING phrase PERFORM statement can serially search an entire seven-dimensional table.
If procedure-name-1 is specified, imperative-statement-1 and the END-PERFORM phrase must not be specified. If procedure-name-1 is omitted, the AFTER phrase must not be specified.
After the conditions specified in the UNTIL phrase are satisfied, control is passed to the next executable statement following the PERFORM statement.
If any of the operands specified in condition-1 or condition-2 is subscripted, reference modified, or is a function-identifier, the subscript, reference-modifier, or function is evaluated each time the condition is tested.
Floating-point data items and literals can be used anywhere a numeric data item or literal can be specified.
When TEST BEFORE is indicated, all specified conditions are tested before the first execution, and the statements to be performed are executed, if at all, only when all specified tests fail. When TEST AFTER is indicated, the statements to be performed are executed at least once, before any condition is tested.
If neither the TEST BEFORE nor the TEST AFTER phrase is specified, the TEST BEFORE phrase is assumed.
The way in which operands are increased or decreased depends on the number of variables specified. In the following discussion, every reference to identifier-n refers equally to index-name-n (except when identifier-n is the object of the BY phrase).
If identifier-2 or identifier-5 is subscripted, the subscripts are evaluated each time the content of the data item referenced by the identifier is set or augmented. If identifier-3, identifier-4, identifier-6, or identifier-7 is subscripted, the subscripts are evaluated each time the content of the data item referenced by the identifier is used in a setting or an augmenting operation.
The following figure illustrates the logic of the PERFORM statement when an identifier is varied with TEST BEFORE.

The following figure illustrates the logic of the PERFORM statement when an identifier is varied with TEST AFTER.

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
At the end of PERFORM statement execution:
The following figure illustrates the logic of the PERFORM statement when two identifiers are varied with TEST BEFORE.

The following figure illustrates the logic of the PERFORM statement when two identifiers are varied with TEST AFTER.

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
AFTER IDENTIFIER-8 FROM IDENTIFIER-9
BY IDENTIFIER-10 UNTIL CONDITION-3
The actions are the same as those for two identifiers, except that identifier-8 goes through the complete cycle each time that identifier-5 is augmented by identifier-7, which, in turn, goes through a complete cycle each time that identifier-2 is varied.
At the end of PERFORM statement execution:
You can produce analogous PERFORM statement actions to the example above with the addition of up to four AFTER phrases.
No matter how many variables are specified, the following rules apply: