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
Labels at scatter plotDear All, I am always fascinated seeing how much useful information can be derived from even the si…
Help for data with multiple quarterly observationsHello and sorry if this question is obvious or incorrect, I have quarterly data from 2007q1 to 2010…
replacing "X" character within a string variable with "9"Hi, I have a string variable that some of its values consist of a combination of numbers and "X" (e.…
Reshaping the Bruegel DatasetGood Day! I am currently trying to reshape the Bruegel Dataset. Currently it is comprised of a year…
Question on looping over files in a directory using local and foreachDear Statalists, Recently I am attempting to deal with some .dta files in a local directory on the …
Subscribe to:
Post Comments (Atom)
0 Response to Grouping individual years into year groups in panel data
Post a Comment