The Basics of DO Loops

DO Statement, Iterative Syntax

The iterative DO statement executes statements between the DO and END statements repetitively, based on the value of an index variable.
Syntax, DO statement, iterative:
DO index-variable=specification-1 <, ...specification-n>;
...more SAS statements...
END;
  • index-variable names a variable whose value governs execution of the DO group.
    Note: Unless you specify to drop it, the index variable is included in the data set that is being created.
    CAUTION:
    Avoid changing the index variable within the DO group.
    If you modify the index variable within the iterative DO group, you might cause infinite looping.
  • specification denotes an expression or series of expressions such ...

Get SAS Certification Prep Guide, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.