SAS – Loops

Next »»
You may encounter situations, when a block of code needs to be executed several number of times. In general, statements are executed sequentially: The first statement in a function is executed first, followed by the second, and so on. But when you want the same set of statements to be executed again and again, we need the help of Loops.

In SAS looping is done by using DO statement. It is also called DO Loop. Given below is the general form of a DO loop statements in SAS.

Flow Diagram

SAS - Loops

Following are the types of DO loops in SAS.

S.N. Loop Type & Description
1 DO Index.
The loop continues from the start value till the stop value of the index variable.
The loop continues till the while condition becomes false.
The loop continues till the UNTIL condition becomes True.
Next »»