DO Statement with a WHILE Clause
conditionally executes statements iteratively
- DO WHILE( expression);
- DO variable=start TO
stop <BY increment>
The inputs to the DO WHILE statement are as follows:
Using a WHILE expression makes possible the conditional
execution of a set of statements iteratively.
The WHILE expression is evaluated at the top of the loop,
and the statements inside the loop are executed repeatedly as
long as the expression yields a nonzero or nonmissing value.
- is an expression that is evaluated at the
top of the loop for being true or false.
- is the name of a variable indexing the loop.
- is the starting value for the looping variable.
- is the stopping value for the looping variable.
- is an increment value.
Note that the incrementing is done
before the WHILE expression is tested.
The following example demonstrates the incremeting:
print x; /* x=100 */
The next example increments the starting value by 2:
do x=1 to 100 by 2 while(y<200);
end; /* at end of loop, x=11 and y=945 */
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.