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.
Program Data Vector
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 ...

Get SAS Certification Prep Guide, 5th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.