The Basics of DO Loops

The Basics of Using Grouping Statements and DO Groups

You can execute a group of statements as a unit by using DO groups.
To construct a DO group, you use the DO and END statements along with other SAS statements.
Syntax, DO group:
DO;
SAS statements
END;
  • The DO statement begins DO-group processing.
  • SAS statements between the DO and END statements are called a DO group and are executed as a unit.
  • The END statement terminates DO-group processing.
Tip:You can nest DO statements within DO groups.
You can use DO groups in IF-THEN/ELSE statements and SELECT groups to execute many statements as part of the conditional action.

Example: DO and END Statements

In this simple DO group, ...

Get SAS Certified Specialist Prep Guide 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.