Language Reference |
iteratively executes a DO group
When the DO group has this form, the statements between the DO and END statements are executed repetitively. The number of times the statements are executed depends on the evaluation of the expressions given in the DO statement.
The start, stop, and increment values should be scalars or expressions with evaluations that yield scalars. The variable is given a new value for each repetition of the group. The index variable starts with the start value, then is incremented by the increment value each time. The iterations continue as long as the index variable is less than or equal to the stop value. If a negative increment is used, then the rules reverse so that the index variable decrements to a lower bound. Note that the start, stop, and increment expressions are evaluated only once before the looping starts.
For example, consider the following statements:
do i=1 to 5 by 2; print 'THE VALUE OF I IS:' i; end;
These statements produce the following output:
I THE VALUE OF I IS: 1 I THE VALUE OF I IS: 3 I THE VALUE OF I IS: 5
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.