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
Margins interaction variables Beta regressionDear Statalisters, I am running a regression with proportions as dependent variable. In the beta re…
diagt commandGood day, I am using diagt command on Stata 14.2 and I am interested in PPV. I am not sure which one…
Generating a dummy for a measurement change in one independent variableDear Statalist, I am currently writing my dissertation and have encountered some difficulties that …
Multiple imputation with panel dataHello everyone, I have a panel dataset with daily data on covid-19 outcomes at country level and ot…
Changing GDPpc to lnGDPpc changes the significance of my resultsHello, I am currently writing my undergrad dissertation, titled "The Macroeconomic Determinants of …
Subscribe to:
Post Comments (Atom)
0 Response to Cumulative Totals in Unbalanced Time Series Data
Post a Comment