SAS - DO WHILE Loop



This DO WHILE loop uses a WHILE condition. The SAS statements are repeatedly executed until the while condition becomes false.

Syntax

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

Example

DATA MYDATA; SUM = 0; VAR = 1; DO WHILE(VAR<6) ; 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