Dear all,
I have a panel data between 1997and 2010. I could only provide an example and not the data I am using.
I have this dataex:
--------------
I apply this code to get:
I need to get the expenditures from the perspective of firm2 such that I use the same code above, but obtain this data:
I generated "expenditure_2_01 " manually, but I still need the right code:
then I will use this code:
I will obtain
------------------ copy up to and including the previous line ------------------
Please could you tell how to generate the variable "expenditure_2_01 "?
Thank you,
I have a panel data between 1997and 2010. I could only provide an example and not the data I am using.
I have this dataex:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int(period firm_id1 firm_id2) float expenditure 2018 110 110 1500 2018 110 120 3000 2018 110 130 4500 2018 120 110 7500 2018 120 120 1500 2018 120 130 9000 2018 130 110 3750 2018 130 120 2250 2018 130 130 4500 end
I apply this code to get:
Code:
bysort firm_id1 period : egen sum_id1=total(expenditure)
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int(period firm_id1 firm_id2) float(expenditure sum_id1) 2018 110 110 1500 9000 2018 110 120 3000 9000 2018 110 130 4500 9000 2018 120 110 7500 18000 2018 120 120 1500 18000 2018 120 130 9000 18000 2018 130 110 3750 10500 2018 130 120 2250 10500 2018 130 130 4500 10500 end
I generated "expenditure_2_01 " manually, but I still need the right code:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int(period firm_id1 firm_id2 expenditure sum_id1 f_id2 f_id1 expenditure_2_01) 2018 110 110 1500 9000 110 110 1500 2018 110 120 3000 9000 110 120 7500 2018 110 130 4500 9000 110 130 3750 2018 120 110 7500 18000 120 110 3000 2018 120 120 1500 18000 120 120 1500 2018 120 130 9000 18000 120 130 2250 2018 130 110 3750 10500 130 110 4500 2018 130 120 2250 10500 130 120 9000 2018 130 130 4500 10500 130 130 4500 end
then I will use this code:
Code:
bysort f_id2 period : egen sum_id2=total(expenditure_2_01)
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int(period firm_id1 firm_id2 expenditure sum_id1 f_id2 f_id1 expenditure_2_01) float sum_id2 2018 110 110 1500 9000 110 110 1500 12750 2018 110 120 3000 9000 110 120 7500 12750 2018 110 130 4500 9000 110 130 3750 12750 2018 120 110 7500 18000 120 110 3000 6750 2018 120 120 1500 18000 120 120 1500 6750 2018 120 130 9000 18000 120 130 2250 6750 2018 130 110 3750 10500 130 110 4500 18000 2018 130 120 2250 10500 130 120 9000 18000 2018 130 130 4500 10500 130 130 4500 18000 end
Please could you tell how to generate the variable "expenditure_2_01 "?
Thank you,
Comment