I have not been able to figure out how to leverage time-series data (tsset) and its efficiencies to calculate a running total across unbalanced panels.
E.g. given the values in "amount" I want to at least create the totals in cumsum
id year amount cumsum
1 2006 9 9
1 2009 12 21
1 2010 4 25
2 2007 6 6
2 2010 10 16
2 2011 8 24
3 2009 14 14
3 2012 6 20
But, ideally, I would create a balanced table that looks like this
id year amount cumsum
1 2006 9 9
1 2007 0 9
1 2008 0 9
1 2009 12 21
1 2010 4 25
1 2011 0 25
1 2012 0 25
2 2006 0 0
2 2007 6 6
2 2008 0 6
2 2009 0 6
2 2010 10 16
2 2011 8 24
2 2012 0 24
3 2006 0 0
3 2007 0 0
3 2008 0 0
3 2009 14 14
3 2010 0 14
3 2011 0 14
3 2012 6 20
I have found a few posts (e.g., here and here) but I was not able to figure out how to efficiently solve this.
Any ideas?
Thank you, in advance,
Ben
Lawrence Berkeley National Lab
Related Posts with Cumulative Totals in Unbalanced Time Series Data
Looping and Recodinglooping and recoding Hello, I am trying to reverse code pt_bbq1_ - pt_bbq14_ below There are 5 poss…
Creating a new variable using foreachHello, I have a dataset that includes 180 variables (day1, day2, day3...day180) that can take on th…
2SLS with two-way fixed effect and clustered error.Hi, I am a Stata beginner. I want to use xtivreg2 to do a 2SLS estimation with two way fixed effect…
Calcolare gli anni di permanenza in un determinato paese conoscendo l'anno di arrivoCiao a tutti!! Avrei bisogno di un consiglio per una ricerca scolastica in Stata. Negli allegati c'è…
Fixed effects panel data model and OLS assumptionsHello everybody, I am running a fixed effects model panel analysis for my masters thesis. My superv…
Subscribe to:
Post Comments (Atom)
0 Response to Cumulative Totals in Unbalanced Time Series Data
Post a Comment