Hello Everyone,
I use Stata 15.
The table below shows customer ID, year, and the value of transactions each customer did with two brands (brand1, and brand2).
I need to calculate the total value of transactions each customer did with each brand in each two consecutive years starting in 1990 (i.e., 1990-1991, 1992-1993, 1994-1995, and so on). That said, transactions in year 1991 should not be added to transactions in year 1992.
Then, I need to calculate the difference between the total transactions with brand1 and brand2, for each two consecutive years, for each customer (for example, transactions with brand1 in 1990-1991 minus transactions with brand2 in 1990-1991)
Thank you very much for your help.
id year brand1 brand2
1 1989 400 0
1 1990 100 50
1 1990 100 0
1 1991 100 0
1 2001 100 0
2 2000 250 0
2 2000 0 300
2 2000 0 690
2 2001 0 230
3 2009 890 0
3 2010 200 0
3 2011 0 2000
4 2013 120 0
4 2015 450 0
4 2015 400 230
4 2015 450 1200
4 2016 110 0
Related Posts with sum of specific consecutive obs
Subgroup within id variable for panel dataI have panel data with an id variable for each person, I want to generate a subgroup identifier base…
Trouble with Dummy VariablesHi, I currently have data on recycling rates for different local authorities in the UK and would li…
Cases show up as missing in new varHi! I am trying to generate a new var RWTEL using combinations of two other variables. (ANY and THR…
how to predict technical efficiency after estimating a true random effcet model.Dear All, I am running a true random effcetmodel, which accounts hetroscedasticity using the sfpanel…
Interaction variables in OLS and FEDear all, I am running OLS and FE estimation. I have difficulties creating the below interactions o…
Subscribe to:
Post Comments (Atom)
0 Response to sum of specific consecutive obs
Post a Comment