I have a Panel dataset, where my id variable is an age bracket categorical variable, called yrbracket. This variable has a category for people between 16 and 24, another for people between 25 and 34, another for people between 35 and 49 and so on.
I am interested in the yearly income by categories. So, every year I will have the income of people between 16 and 24, the income for people between 25 and 39 and so on.
I would like to show the percentage change of the income throughout the years, with the income of the first year (1992) being the base income. That is, I would like to divide every income of every year after 1992 by the income of 1992, for every age bracket. In this manner, I will be able to plot the yearly variation of income for every age bracket.
I am however having trouble with this task. I am trying to create a variable, for every age bracket category, which is equal to the income of that age category's income in the first year. So, if in the first year people between 16 and 24 had an income of $800, I would like a variable that repeats that 800 for every year after that, for people between 16 and 24. In this manner, I will then be able to divide the normal yearly income variable by this new variable, which would give me the change of income taking the first income as base.
I tried doing that with this code:
Code:
bysort yrbracket: generate percent = income if year == 1992
Any help would be highly appreciated
0 Response to Variable with same value each year by category
Post a Comment