Showing posts with label DO-WHILE. Show all posts
Learning SAS - Looping with Condition (DO WHILE & DO UNTIL)
We learnt about Conditional processing and Iterative Processing, but what if we could combine both of them and use effectively? Hence comes DO WHILE & DO UNTIL.
Problem 1:
Generate a table of integers and squares starting at 1 and ending when the square
value is greater than 100. Use either a DO UNTIL or DO WHILE statement to
accomplish this.
Solution:
Output:
Learning:
Download the code here
Problem 1:
Generate a table of integers and squares starting at 1 and ending when the square
value is greater than 100. Use either a DO UNTIL or DO WHILE statement to
accomplish this.
Solution:
data A01_intsqrs; integer = 1; do while (square <= 100); /*do until (square > 100);*/ square = integer ** 2; output; integer + 1; end; run; proc print data=A01_intsqrs; run;
Output:
Learning:
- How DO-WHILE & DO-UNTIL works
- Controlling the loop with a condition
Download the code here
Friday, September 18, 2015
Posted by Netbloggy