I have an upcoming deadline and I have a huge problem I cannot solve, so any help whatsoever will be highly appreciated.
I have a panel dataset, running for 27 years, with thousands of individual observations every year. The identification variable is called pidp, and the time variable is called year.
I have created a categorical variable which divides individuals based on the generation they're born in with the following code:
Code:
bysort pidp wave: generate cohort = 1 if doby >= 1945 & doby <= 1949 & age >= 16 replace cohort = 2 if doby >= 1950 & doby <= 1954 & age >= 16 replace cohort = 3 if doby >= 1955 & doby <= 1959 & age >= 16 replace cohort = 4 if doby >= 1960 & doby <= 1964 & age >= 16 replace cohort = 5 if doby >= 1965 & doby <= 1969 & age >= 16 replace cohort = 6 if doby >= 1970 & doby <= 1974 & age >= 16 replace cohort = 7 if doby >= 1975 & doby <= 1979 & age >= 16 replace cohort = 8 if doby >= 1980 & doby <= 1984 & age >= 16 replace cohort = . if age <= 15
Code:
bysort pidp wave: generate yrcategory = 1 if age >= 16 & age <= 20 replace yrcategory = 2 if age >= 21 & age <= 25 replace yrcategory = 3 if age >= 26 & age <= 30 replace yrcategory = 4 if age >= 31 & age <= 35 replace yrcategory = 5 if age >= 36 & age <= 40 replace yrcategory = 6 if age >= 41 & age <= 45 replace yrcategory = 7 if age >= 46 & age <= 50 replace yrcategory = 8 if age >= 51 & age <= 55 replace yrcategory = 9 if age >= 56 & age <= 60 replace yrcategory = 10 if age >= 61 & age <= 65 replace yrcategory = 11 if age >= 65 replace yrcategory = . if age <= 15
Array
The coding I use to create this graph is:
Code:
preserve collapse fimngrs_dv [pweight = weight], by( cohort year ) xtset cohort year, yearly xtline fimngrs_dv, overlay scheme(s1mono) plot2opts(lp(-)) plot3opts(lp(-.-)) leg(row(1))
My problem is the following:
I would like to recreate the graph, but, on the x axis, I would like to have the yrcategory variable instead of the years. In this way, I will be able to compare the mean wage of different generations, considering how much each generation earned at every age.
What I am trying to recreate is a graph similar to the one made by Afman. The graph is graph number 8 at page 5 here: https://ec.europa.eu/info/sites/defa...e/eb053_en.pdf
I tried running the code
Code:
collapse fimngrs_dv [pweight = weight], by( cohort yrcategory ) xtset cohort yrcategory, yearly
"repeated time values within panel
r(451)"
Thanks in advance for the help!
0 Response to Panel data: plotting advanced graph
Post a Comment