Good mornign everyone,
I need help with my panel dataset on trade. I have 5726 dyads over the period 1960 - 2016 (unbalanced). For every dyad-year I have multiple observations and I would like to sum these observations into one single value. That is why I am using
. However I do not understand how to interpret the option interval. In my case the interval is given by year, therefore I have to tell STATA to count in the interval 1960 - 2016.
To make it clear I give you an example of my dataset:
So what I need is to create a new variable for each dyad (id). In this case I would like to have:
My attempt is
but it is wrong. I tried many combinations but I cannot find a solution.
Please, any help is much appreciated!
I need help with my panel dataset on trade. I have 5726 dyads over the period 1960 - 2016 (unbalanced). For every dyad-year I have multiple observations and I would like to sum these observations into one single value. That is why I am using
Code:
rangestat
To make it clear I give you an example of my dataset:
Country A | Country B | year | value | id |
Italy | Germany | 1960 | 1 | 1 |
Italy | Germany | 1960 | 1 | 1 |
Italy | Germany | 2016 | 1 | 2 |
Germany | Italy | 1960 | 1 | 3 |
Germany | Italy | 1960 | 1 | 3 |
id | value_sum |
1 | 2 |
2 | 1 |
3 | 2 |
Code:
rangestat (sum) value, interval(year -1 .) by(id)
Please, any help is much appreciated!
Comment