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,700 courses taught by industry experts.

Checking the condition

Checking the condition

- [Narrator] Many times DO UNTIL loops and DO WHILE loops produce the same result. A subtle but important difference between the two is when the condition is checked. For a DO UNTIL loop, the condition is always checked at the bottom of the DO loop. For a DO WHILE loop, the condition is always checked at the top of the DO loop. This difference can cause different results to be produced. Let's use our savings example in a slightly different scenario. This time the input table, savings2, includes the amount of savings already earned for each individual, so we're no longer starting with a savings value of zero. Notice that Linda has already reached the desired savings of 3000. Even though her savings has exceeded the target, the DO UNTIL loop will execute once because the condition is not checked until the bottom of the DO loop. The DO WHILE will not execute at all because the condition is checked at the top of the DO…

Contents