The general understanding is that a DO WHILE statement evaluates the condition at the top of the loop while a DO UNTIL evaluates the condition at the bottom of the loop. And this holds true in an ordinary DO WHILE/DO UNTIL statement and can be demonstrated by using output statements which show that in a DO WHILE, the index "i" is not incremented beyond the upper limit of the do loop. Whereas, in a DO UNTIL, the index will be incremented by one value beyond the limit of the do loop. Question: How come the converse seems to be the case in the examples below i.e. the index "i" in the DO WHILE statement is incremented to 6 whereas, it stops at 5 in the DO UNTIL? Thx **** How many iterations will this loop execute before terminating ****; data dowhile; do i = 1 to 10 while(x le 4); output; x + 1; output; end; output; run; data dountil; do i = 1 to 10 until(y gt 4); output; y + 1; output; end; output; run;
... View more