English 中文(简体)
SAS - Loops
  • 时间:2024-11-03

SAS - Loops


Previous Page Next Page  

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_do_while_loop.jpg

Following are the types of DO loops in SAS.

Sr.No. Loop Type & Description
1 DO Index.

The loop continues from the start value till the stop value of the index variable.

2 DO WHILE.

The loop continues till the while condition becomes false.

3 DO UNTIL.

The loop continues till the UNTIL condition becomes True.

Advertisements