My data looks like this:
loc_ID year_begin year_end year observations
cha89 2002 2004 2002 28
cha89 2002 2004 2003 28
cha89 2002 2004 2004 14
nin21 2001 2003 2001 90
nin21 2001 2003 2002 12
nin21 2001 2003 2003 99
I want to calculate the sum of observations
in the time interval (year_begin
to year_end
) per loc_ID
. So in the above example, my output would be like this:
loc_ID year_begin year_end observations
cha89 2002 2004 70
nin21 2001 2003 201
How can I do this?