SAS - DO Index Loop
Advertisements
This DO Index loop uses a index variable for its start and end value. The SAS statements are repeatedly executed until the final value of the index variable is reached.
Syntax
DO indexvariable = initialvalue to finalvalue ; . . . SAS statements . . . ; END;
Example
DATA MYDATA1; SUM = 0; DO VAR = 1 to 5; SUM = SUM+VAR; END; PROC PRINT DATA = MYDATA1; RUN;
When the above code is executed, it produces the following result
sas_loops.htm
Advertisements