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
Too much margin on x-axis with graph combineHi Statalists, I am combining four graphs with datetime on the x-axes. The individual graphs have a…
Ordered Regression (dependent variable)Hallo Statalist, i am trying to find out the effect of the macro variables on the credit Rating in …
Error 134: too many valuesHello STATA community, i am running a gravity model with exporter_time_FE, importer_time_FE and cou…
Set baseline category of date variableI want to set the baseline category of a date variable. I thought of using fvset, see below. It does…
graphical presentationHi, I have a data of average steps over 12 weeks. How to use histogram/bar graph in stata to represe…
Subscribe to:
Post Comments (Atom)
0 Response to Cumulative Totals in Unbalanced Time Series Data
Post a Comment