Hello,
I have a list of manufacturers by period and I am trying to calculate a delta like so:
I have been trying to do
but keep getting syntax errors. Is there a way to do this in stata?
Thanks!
I have a list of manufacturers by period and I am trying to calculate a delta like so:
| time_period | chocolate_type | manufacturer_count | delta |
| 2011_Q1 | White | 3 | -- |
| 2011_Q2 | White | 4 | 1 |
| 2011_Q3 | White | 4 | 0 |
| 2011_Q4 | White | 3 | -1 |
| 2011_Q1 | Dark | 6 | -- |
| 2011_Q2 | Dark | 8 | 2 |
| 2011_Q3 | Dark | 7 | -1 |
| 2011_Q4 | Dark | 10 | 3 |
HTML Code:
bysort chocolate_type time_period: gen delta = manufacturer_count[_N] - manufacturer_count[_N -1]
Thanks!

Comment