I'm quite sure it does. Let's go through the code again with comments. But before... do you understand the mechanics of data step? Everything is quite easy. SAS just goes through all commands between data and run statement and perform commands. If there is no explicit output statement, SAS performs output just after the last command and before run. The set statement just reads a row (next row) from data set (test in our case). /* this is the part, where you read test sample */ data test; infile "F:\data\test.csv" DSD MISSOVER; input return resq; run; /* we are going to perform data step and write results to sim */ data sim; /* take a new row from test */ set test; /* here we tell that 'a' and 'sig' will not be reseted while passing set statement. That means if I set 'a' to 0.3 on the first row and will not change it through the code, it'll be 0.3 for each row */ retain a sig; /* init values on the first row. _n_ - is automic variable which is the 'number of row' or amount of times you performed set */ if _n_ = 1 then do; a=0.3; sig = 1.0; end; /* for each line we make a new random variable 'v' */ v = rannor(123457); /* epsi is set to the value v * sig. On the first time we go through this line 'sig' is equal to 1.0. However, since it retained and is modified later, */ /* we will have here the value from previous line (calculated in (X) row) */ epsi = v*sig; /* the (Y) row */ sig2 = resq + a*sig*sig; /* Here is the row (X). sig is now has the value of sqrt of sig2 and this value will be used for the next row in 'test' in row (Y) */ sig = sqrt(sig2); /* write results to sim dataset */ output ; run;
... View more