Hello everyone !
I am currently using a dataset of bilateral migration flows between countries. Here is an example to illustrate the shape of my dataset.
YEAR ORIG DEST NB
2000 A B 50
2000 A C 25
2000 B A 10
2000 B C 20
2000 C A 5
2000 C B 0
2005 A B 60
2005 A C 10
2005 B A 10
2005 B C 5
2005 C A 0
2005 C B 0
From this information, I want to aggregate the number of migrants (NB) in order to obtain emigration (EMIG) the total number of migrants leaving the country of origin (ORIG) and immigration (IMMIG) total number of migrants arriving in the country of origin.
YEAR ORIG EMIG IMMIG
2000 A 75 15
2000 B 30 50
2000 C 5 45
2005 A 70 10
2005 B 15 60
2005 C 0 15
I managed to get the emigration with the following line :
But I do not manage to get the immigration by country of origin. Only by the country of destination.
Has anyone any input to help me solve this issue?
Thank you !
RJ
I am currently using a dataset of bilateral migration flows between countries. Here is an example to illustrate the shape of my dataset.
YEAR ORIG DEST NB
2000 A B 50
2000 A C 25
2000 B A 10
2000 B C 20
2000 C A 5
2000 C B 0
2005 A B 60
2005 A C 10
2005 B A 10
2005 B C 5
2005 C A 0
2005 C B 0
From this information, I want to aggregate the number of migrants (NB) in order to obtain emigration (EMIG) the total number of migrants leaving the country of origin (ORIG) and immigration (IMMIG) total number of migrants arriving in the country of origin.
YEAR ORIG EMIG IMMIG
2000 A 75 15
2000 B 30 50
2000 C 5 45
2005 A 70 10
2005 B 15 60
2005 C 0 15
I managed to get the emigration with the following line :
Code:
bysort YEAR ORIG : egen EMIG = sum(NB)
Has anyone any input to help me solve this issue?
Thank you !
RJ
Comment