Dear all,
I am trying to create a dummy variable that indicates whether a variable increases over time or not. I have a variable 'perrank' that indicates the place of an individual in a wealth distribution. For example, ID=101 in year = 2015 with perrank = 86, indicates that an individual in 2015 belonged to the top 14 percent. Now I want to calculate whether that person's place in the wealth distriution increases over time. I want to create a dummy that says 1 if increase over time and 0 if not. So if ID =101 in year = 2016 with perrank = 87, the dummy should have a 1, because the perrank variable increased. Preferably, I would be able to change the degree of change. For example, whether the increase is one percentile or two percentiles.
I have seen this forum (https://www.statalist.org/forums/for...r-time-periods) but I could not write the code to solve my problem. It is probably something like ' bysort id (year), sort: gen changed = .............'. I have panel data. The ultimate goal is to calculate the probability of rising in the wealth distribution after receiving inheritance.
Thank you in advance.
Best,
Timo
I am trying to create a dummy variable that indicates whether a variable increases over time or not. I have a variable 'perrank' that indicates the place of an individual in a wealth distribution. For example, ID=101 in year = 2015 with perrank = 86, indicates that an individual in 2015 belonged to the top 14 percent. Now I want to calculate whether that person's place in the wealth distriution increases over time. I want to create a dummy that says 1 if increase over time and 0 if not. So if ID =101 in year = 2016 with perrank = 87, the dummy should have a 1, because the perrank variable increased. Preferably, I would be able to change the degree of change. For example, whether the increase is one percentile or two percentiles.
I have seen this forum (https://www.statalist.org/forums/for...r-time-periods) but I could not write the code to solve my problem. It is probably something like ' bysort id (year), sort: gen changed = .............'. I have panel data. The ultimate goal is to calculate the probability of rising in the wealth distribution after receiving inheritance.
Thank you in advance.
Best,
Timo

Comment