Posted by : Netbloggy Friday, September 18, 2015

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:

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

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Popular Post

Blogger templates

Total Pageviews

Powered by Blogger.

- Copyright © nulldata -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -