I am looking to populate a variable that has missing numbers for future years (say 2018 through 2030). What I have is a population number for 2017, and I have given growth percents for the future years. So, for 2018, I want to take the population value (say 800) from the last observation for year 2017 and multiply that by my growth percent that I have stored in the observation for 2018. I tried using a retain statement, and I was able to get this to work for the first year, but I am unable to get it to carry over for the remaining years. My data structure is as follows: year population growth_percent 2017 800 1.01 2018 x1 1.06 2019 x2 1.08 2020 x3 1.11 2021 x4 1.5 2022 x5 1 I need to dynamically calculate the numbers for x1 - x5. X1 should equal 800 * 1.06. Then X2 should eqaul X1 * 1.08. I have tried the following code, but I am only able to populate X1. I can't figure out how to pass the X1 value to the next observation in order to calculate X2: data populations; set pop; retain lastpop; output; lastpop= (population) * (growth_percent); run; Much Thanks!
... View more