Previous Page | Next Page

Statements

DO WHILE Statement



Executes statements in a DO-loop repetitively while a condition is true.
Valid: in a DATA step
Category: Control
Type: Executable

Syntax
Arguments
Details
Comparisons
Examples
See Also

Syntax

DO WHILE (expression);
...more SAS statements...
END;


Arguments

(expression)

is any SAS expression, enclosed in parentheses. You must specify at least one expression.


Details

The expression is evaluated at the top of the loop before the statements in the DO loop are executed. If the expression is true, the DO loop iterates. If the expression is false the first time it is evaluated, the DO loop does not iterate even once.


Comparisons

There are three other forms of the DO statement:


Examples

These statements repeat the loop while N is less than 5. The expression N<5 is evaluated at the top of the loop. There are five iterations in all (0, 1, 2, 3, 4).

n=0;
   do while(n<5);
      put n=;
      n+1;
   end;


See Also

Statements:

DO Statement

DO Statement, Iterative

DO UNTIL Statement

Previous Page | Next Page | Top of Page