|
Chapter Contents |
Previous |
Next |
| Language Reference |
The DO statement specifies that the statements following the DO statement are executed as a group until a matching END statement appears. DO statements often appear in IF-THEN/ELSE statements, where they designate groups of statements to be performed when the IF condition is true or false.
For example, consider the following statements:
if x=y then
do;
i=i+l;
print x;
end;
print y;
The statements between the DO and END statements (called
the DO group) are performed only if X = Y;
that is, only if all elements of X are
equal to the corresponding elements of Y.
If any element of X is not equal to the corresponding
element of Y, the statements in the DO group are
skipped and the next statement is executed, in this case
print y;DO groups can be nested. Any number of nested DO groups is allowed. Here is an example of nested DO groups:
if y>z then
do;
if z=0 then
do;
z=b*c;
x=2#y;
end;
end;
It is good practice to indent the statements
in a DO group as shown above so that their
positions indicate their levels of nesting.
|
Chapter Contents |
Previous |
Next |
Top |
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.