Specifies a group of statements to be executed as a unit.
| Valid in: | DATA step |
|---|---|
| Categories: | CAS |
| Control | |
| Type: | Executable |
| See: | DOLIST syntax (definition) |
| Forms of the Iterative DO Loop in SAS Programmer’s Guide: Essentials |
Table of Contents
Use the DO statement for simple DO group processing.
The DO statement is the simplest form of DO group processing. The statements between the DO and END statements are called a DO group. You can nest DO statements within DO groups.
You can also use DOLIST syntax to iterate over a list of values. For more information, see DOLIST syntax in SAS Programmer’s Guide: Essentials.
A simple DO statement is often used within IF-THEN/ELSE statements to designate a group of statements to be executed depending on whether the IF condition is true or false.
There are three other forms of the DO statement:
In this simple DO group, the statements between DO and END are performed only when YEARS is greater than 5. If YEARS is less than or equal to 5, statements in the DO group do not execute, and the program continues with the assignment statement that follows the ELSE statement.
if years>5 then
do;
months=years*12;
put years= months=;
end;
else yrsleft=5-years;