Each observation of the dataset I'm working with is a person with a variable age. I created a variable, i, the value of which is the total number of people with that age. For example, if there are 56 people with age 5 then everyone with age 5 has 56 for the variable i. I did this with the following line of code:
egen i = total(age == age), by(age)
but now I want to make a variable, d, the value of which is (i for age) - (i for age+1). For example, if there are 50 people with age 6 then all observations of age 5 will have 6 as their 'd' value. Any ideas on how to accomplish this?
egen i = total(age == age), by(age)
but now I want to make a variable, d, the value of which is (i for age) - (i for age+1). For example, if there are 50 people with age 6 then all observations of age 5 will have 6 as their 'd' value. Any ideas on how to accomplish this?
Comment