I have panel data with individual identifier id and time variable year. The year of an event, such as getting married, is recorded for each individual, and for some individuals the event happens more than once in the sample period.
does the job when a need a table depicting for how many people the event happened in each year.
But I also need line plots showing the number of events per year (along with other characteristics of the individuals with an event). The natural way for me to go was collapsing the data, like this:
However, as the screenshot below shows, the numbers differ and I do not see why this is so. What am I missing? Which is the correct way to get what I need, namely, weddings per year, in a way that I can draw a line graph?
Code:
xttab eventyear
But I also need line plots showing the number of events per year (along with other characteristics of the individuals with an event). The natural way for me to go was collapsing the data, like this:
Code:
bys id (year): keep if _seq==1 // only keep the first obs for each individual (individuals with more than one event will also have _seq==1 more than once) collapse (count) weddings=id (mean) meaninc_grooms=income, by(eventyear)
Comment