SAS - DO UNTIL Loop


Advertisements


The DO UNTIL loop uses a UNTIL condition. The SAS statements are repeatedly executed till the UNTIL condition becomes TRUE.

Syntax

DO UNTIl (variable  condition);
. . . SAS statements . . . ;
END;

Example

DATA MYDATA;
SUM = 0;
VAR = 1;
DO UNTIL(VAR>5);
   SUM = SUM+VAR;
   VAR+1;
END;
   PROC PRINT;
   RUN;

When the above code is executed, it produces the following result −

do_index_result.JPG

sas_loops.htm

Advertisements