Conditionally Executing DO Loops
The iterative DO statement specifies a fixed number of iterations for the DO loop. However, there are times when you want to execute a DO loop until a condition is reached or while a condition exists, but you do not know how many iterations are needed.
Suppose you want to calculate the number of years required for an investment to reach $50,000. In the DATA step below, using an iterative DO statement is inappropriate because you are trying to determine the number of iterations required for Capital to reach $50,000.
data work.invest; do year=1 to ? ; Capital+2000; capital+capital*.10; end; run;
The DO WHILE and DO UNTIL statements enable you to execute DO loops based on whether a condition is true ...