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
Panel Data: xttest2 errorHi, I am running a long panel (t=15, N=8), 8 countries and 15 years. after running for fe I ran the…
Generate var3 for if var1>var2I am trying to make a new variable that shows if people have a higher value in one variable than ano…
Translating datasets from Russian to English languageHi All, I was wondering if there is any command in Stata 15 that could translate variables and valu…
merge vars do not uniquely identify observations in master data - but no duplicates foundI am struggling to perform a 1:m merge on two merge variables that are both string variables. When I…
Help - Create Variable Indicating Percent who Agree or Strongly Agree by DepartmentHi, All, I have survey data with responses from individuals (n = 1077, some missing data), and thos…
Subscribe to:
Post Comments (Atom)
0 Response to Grouping individual years into year groups in panel data
Post a Comment