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
Tobit or Fractional Regression?I have an index variable that I created meant to measure the sophistication of different military ai…
Generate dummies with start and end dates, and convert data to long formatHi all, I have a panel dataset, monthly between 1998m12-2018m12 for 28 countries. Here is an exampl…
Panel Regression - RE/FEGood afternoon, This might be a simple question but here is my problem: I want to understand or se…
Calculating IRR - keep last observation of certain category by FundIDHi, I have private equity cashflow data from which I want to calculate the IRR for every fund. The…
Creating Unique Dummy Variables versus i. commandHi Stata Experts: Is there a benefit to creating individual dummy variables for RACE versus using th…
Subscribe to:
Post Comments (Atom)
0 Response to Cumulative Totals in Unbalanced Time Series Data
Post a Comment