Hello
I have data for more than 1000 municipalities in Colombia, and for each, 20 years of observations. I was wondering how I could group the years. I mean, instead of having 1990, 1991, 1992... 2018 to have 1990-1992, 1993-1995, 1996-1998 and so on. Then I want to add the values of the variables in each group of years. The code I am using is
gen group=.
replace group=19901992 if year>=1990 & year<=1992
replace group=19931995 if year>=1993 & year<=1995
replace group=19951998 if year>=1996 & year<=1998
replace group=19982001 if year>=1990 & year<=2001
bysort group: egen sum_var=sum(var)
for each of the variables, but in the end i get all my results the same rather than grouped by each year group.
Thank you
Related Posts with Grouping individual years into year groups in panel data
How to delete specific observations?I have 3 variables that I want to construct an aggregate variable with: racfew rachaf racmost I hav…
Student Course Enrollment Data (Long to Wide): Transpose, Reshape, Collapse?My data (student course enrollment) is currently in long form, and I would ideally like to reshape i…
how to simplify when 2 do files have a lot of same contents?My 1st do file is (a much shorter version): Code: clear * use "/Users/zhaoyao/Documents/wiki/daily_…
Invalid name error in foreach loopHi, I'm having trouble in running a foreach loop and it keeps showing the invalid name error to me. …
HELP: Reshaping + Cleaning DataHello Statlist, I'm am currently working on reshaping the following dataset: Code: * Example gene…
Subscribe to:
Post Comments (Atom)
0 Response to Grouping individual years into year groups in panel data
Post a Comment