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 ? ; 
The DO WHILE and DO UNTIL statements enable you to execute DO loops based on whether a condition is true ...

Get SAS Certified Specialist Prep Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.