Dear Stata users,
I am constructing my dataset based on bilateral trade variables from 1996 to 2020. My goal is to add variables useful for creating a gravity model. For this, I have merged population data that matches with the country of origin: the data merged is thus "countryname_exp" and "total_pop_origin". I would like to create another column "total_pop_dest" which copies the population data that I have merged to the dataset, but based on the importer country and on the year. Maybe with a code similar to vlookup on excel?
I hope this is clear, I'm not very familiar with Stata.
Below you will find the dataex to show you my data:
I am constructing my dataset based on bilateral trade variables from 1996 to 2020. My goal is to add variables useful for creating a gravity model. For this, I have merged population data that matches with the country of origin: the data merged is thus "countryname_exp" and "total_pop_origin". I would like to create another column "total_pop_dest" which copies the population data that I have merged to the dataset, but based on the importer country and on the year. Maybe with a code similar to vlookup on excel?
I hope this is clear, I'm not very familiar with Stata.
Below you will find the dataex to show you my data:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input int year str52 countryname_exp double total_pop_origin str32 importer_name float total_pop_dest 1996 "Hong Kong SAR, China" 6435500 "France" . 1996 "Austria" 7959017 "Malta" . 1996 "France" 59753095 "Belgium-Luxembourg" . 1996 "United Kingdom" 58166950 "Thailand" . 1996 "Austria" 7959017 "Hungary" . 1996 "Sweden" 8840998 "Algeria" . 1996 "Czechia" 10315241 "Hungary" . 1996 "Mexico" 93147045 "Austria" . 1996 "United Kingdom" 58166950 "Ukraine" . 1996 "Netherlands" 15530498 "Austria" . 1996 "Austria" 7959017 "Indonesia" . 1996 "New Zealand" 3732000 "Argentina" . 1996 "Germany" 81914831 "Switzerland" . 1996 "Ukraine" 51057800 "Mexico" . 1996 "Hong Kong SAR, China" 6435500 "Japan" . 1996 "Ireland" 3637510 "TFYR of Macedonia" . 1996 "France" 59753095 "Turkey" . 1996 "Canada" 29610218 "Switzerland" . 1996 "Germany" 81914831 "TFYR of Macedonia" . 1996 "Switzerland" 7071850 "Thailand" . 1996 "Korea, Rep." 45524681 "Indonesia" . 1996 "United Arab Emirates" 2539121 "Japan" . 1996 "Brazil" 164614682 "Venezuela" . 1996 "" . "Italy" . 1996 "France" 59753095 "Belize" . 1996 "Australia" 18311000 "Indonesia" . 1996 "Switzerland" 7071850 "United Kingdom" . 1996 "Belgium" 10156637 "Denmark" . 1996 "Switzerland" 7071850 "Hungary" . 1996 "Hong Kong SAR, China" 6435500 "Canada" . 1996 "Czechia" 10315241 "Russian Federation" . 1996 "Denmark" 5263074 "Malaysia" . 1996 "Germany" 81914831 "Belgium-Luxembourg" . 1996 "Russian Federation" 148160129 "Turkey" . 1996 "Japan" 125757000 "Sweden" . 1996 "Malaysia" 21017619 "Argentina" . 1996 "India" 982365248 "Pakistan" . 1996 "Australia" 18311000 "Indonesia" . 1996 "" . "Japan" . 1996 "Finland" 5124573 "Poland" . 1996 "Spain" 39889852 "United Arab Emirates" . 1996 "Germany" 81914831 "Venezuela" . 1996 "Indonesia" 199901231 "USA" . 1996 "Italy" 56860281 "Ireland" . 1996 "Turkiye" 59423278 "United Kingdom" . 1996 "China" 1217550000 "Poland" . 1996 "India" 982365248 "Singapore" . 1996 "Switzerland" 7071850 "Morocco" . 1996 "Malaysia" 21017619 "France" . 1996 "Malaysia" 21017619 "Argentina" . 1996 "Australia" 18311000 "Indonesia" . 1996 "Singapore" 3670704 "Bulgaria" . 1996 "France" 59753095 "Russian Federation" . 1996 "France" 59753095 "Italy" . 1996 "United States" 269394000 "Oman" . 1996 "United Kingdom" 58166950 "Nigeria" . 1996 "Germany" 81914831 "Egypt" . 1996 "Germany" 81914831 "Venezuela" . 1996 "Morocco" 27383472 "France" . 1996 "Japan" 125757000 "Czechia" . 1996 "Egypt, Arab Rep." 63601632 "Belgium-Luxembourg" . 1996 "Germany" 81914831 "Hungary" . 1996 "Austria" 7959017 "Tunisia" . 1996 "Libya" 5036173 "United Kingdom" . 1996 "Sweden" 8840998 "Côte d'Ivoire" . 1996 "Belgium" 10156637 "Singapore" . 1996 "France" 59753095 "Russian Federation" . 1996 "France" 59753095 "Russian Federation" . 1996 "Sweden" 8840998 "Bolivia (Plurinational State of)" . 1996 "Germany" 81914831 "Sri Lanka" . 1996 "Denmark" 5263074 "Greenland" . 1996 "Morocco" 27383472 "New Zealand" . 1996 "" . "Mexico" . 1996 "Australia" 18311000 "Indonesia" . 1996 "France" 59753095 "China, Hong Kong SAR" . 1996 "India" 982365248 "Mexico" . 1996 "Japan" 125757000 "Venezuela" . 1996 "Germany" 81914831 "Venezuela" . 1996 "Norway" 4381336 "Colombia" . 1996 "Korea, Rep." 45524681 "Malaysia" . 1996 "United Arab Emirates" 2539121 "Switzerland" . 1996 "Mozambique" 15960445 "Czechia" . 1996 "Malaysia" 21017619 "Netherlands" . 1996 "India" 982365248 "Thailand" . 1996 "Hong Kong SAR, China" 6435500 "Turkey" . 1996 "Australia" 18311000 "Solomon Isds" . 1996 "Italy" 56860281 "Slovenia" . 1996 "Portugal" 10063945 "Greece" . 1996 "Mexico" 93147045 "Cuba" . 1996 "France" 59753095 "Norway" . 1996 "Korea, Rep." 45524681 "Italy" . 1996 "Denmark" 5263074 "China, Hong Kong SAR" . 1996 "United States" 269394000 "Argentina" . 1996 "Ireland" 3637510 "United Kingdom" . 1996 "Switzerland" 7071850 "Romania" . 1996 "United States" 269394000 "Malaysia" . 1996 "Greece" 10608800 "Spain" . 1996 "Netherlands" 15530498 "Other Asia, nes" . 1996 "Singapore" 3670704 "United Kingdom" . 1996 "Dominica" 70933 "Rep. of Korea" . end
Comment