From the course: SAS® 9.4 Cert Prep: Part 13 Processing Repetitive Code

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Conditional DO loops

Conditional DO loops

- [Instructor] So far, you've seen examples of iterative DO loops, meaning you specify the number of times you want to iterate through the statements. In this example, the DO loop iterates 12 times, corresponding to 12 months. There're times when you don't know how many times the DO loop needs to iterate. For example, suppose you want the DO loop to stop when each person has saved more than $3,000. You can use a conditional DO loop to iterate as many times as necessary to meet the condition. There're two variations of the conditional DO loop. Do until and do while. Do until executes until a condition is true, Do while executes while a condition is true. For both methods, the expression must be enclosed in parentheses. In this example, the do until loop executes until savings is greater than 3,000. The do while loop uses the opposite expression. The do while loop executes while savings is less than or equal to 3,000.…

Contents