I want to do a temporal decomposition using STATA. Assume the following data below where x= y*z
year |
x |
y |
z |
2015 |
8 |
4 |
2 |
2016 |
12 |
3 |
4 |
2017 |
16 |
4 |
4 |
It is not necessary to show the entire decomposition but a crucial step is calculating the changes in the variables:
year |
x |
y |
z |
delta x |
delta y |
delta |
2015 |
8 |
4 |
2 |
|
|
|
2016 |
12 |
3 |
4 |
4 |
-1 |
2 |
2017 |
16 |
4 |
4 |
4 |
1 |
0 |
But this involves subtracting one row from the previous row . However, nearly all the STATA functions refer to expression
within a row. How can I create a loop which calculates and generates the variables delta x,y,z?
Thanks!
Rutger
0 Response to Temporal decomposition - Function using data from 2 different rows of a table
Post a Comment