145 data newbank;
146 do year = 1 to 3;
147 set banks;
148 capital + 5000;
NOTE: There were 3 observations read from the data set WORK.BANKS.
NOTE: The data set WORK.NEWBANK has 1 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds
In the background, SAS uses the Program Data Vector (PDV) to complete calculations and write values to the output dataset when a RUN statement or an OUTPUT statement occurs. The processing of this program is as follows:
STEP 1: The statement do year = 1 to 3; runs. SAS loops 3 times for values of year =1,2, and 3 and in each loop, the year value is incremented such that when year = 4, SAS stops. Here the value of year is set to 4.
STEP 2: The statement SET banks is used to read in values. Here, values from the set statement are automatically retained in the PDV. Thus, each time the last value of data set will be retained in last observation.
STEP3 : The statement Capital + 500 ; is equal to:
RETAIN capital 0 ;
capital = capital + 500 ;
After the third iteration, a value of 1500 is set for variable capital.
The one and only FREE resource for general SAS online training as well as study guides for the SAS Base Certification. My goal is to create the SAS Certification prep guide that I never found but always wanted. This should also be a place to come if you are new to the language but are simply looking for online SAS training.