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.

Combining iterative and conditional DO loops

Combining iterative and conditional DO loops - SAS Tutorial

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

Combining iterative and conditional DO loops

- [Instructor] You can combine a conditional do loop with an iterative do loop. The iterative syntax comes before the conditional syntax. The do loop stops executing when the stop value is exceeded or the condition is met, whichever is first. Suppose we need to reach a savings value of 5,000 conditional, but we don't want to go beyond 12 months, iterative. For the do until loop, the condition is checked before the index column is incremented at the bottom of the loop. So here, if the value of savings is greater than 5,000, the do loop processing stops and month is not incremented. If the value of savings is less than 5,000, month is incremented and the value of month is checked against the stop value. For the do while loop, the condition is checked at the top of the loop and the index column is incremented at the bottom of the loop. So here if savings is less than or equal to 5,000, the do loop executes and the index…

Contents