Hello all,

I need to repeat 3 line of commands in stata to create updated observations for three variables (FV1, ID10066, amort1) on my dataset, the calculation for the three happens depending on each other, therefore each row is needed for calculations of the next row. When I manually repeat these lines and run them then I get the desired result. However I look for a way to automatically do this. I also looked into writing a loop to do so but I could not figure out what should be done to get it write. The commands are the following: (first 4 observations are filled out already before getting to these lines of code)

replace FV1 = FV1[_n-1] - amort1 if date > date[3]
replace ID10066 = (FV1[_n-1])*rq if date > date[3]
replace amort1 = pmt - ID10066 if date > date[4]

Please let me know if I need to add extra information for clarity. But the purpose here is only to find a way to repeat these lines automatically instead of typing/running them again and again.

Thank you all.