Constructing DO Loops
DO Loop Execution
Here is how the DO loop executes in the DATA step. This example sums the interest that was earned each month for a one-year investment.
data work.earnings; Amount=1000; Rate=0.75/12; do month=1 to 12; Earned+(amount+earned)*rate; end; run;
This DATA step does not read data from an external source. When submitted, it compiles and then executes only once to generate data. During compilation, the program data vector is created for the Work.Earnings data set.
When the DATA step executes, the values of Amount and Rate are assigned.
Next, the DO loop executes. During each execution of the DO loop, the ...