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