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