Hi all,
I have numerous countries FDI data (1985-2022) with each couyntry in a seperate excel workbook named after respective country. When I import desired sheet from a given excel workbook for one country like Afghanistan the data looks like this
import excel "Afghanistan.xlsx", sheet("inflow-M") firstrow clear
dataex Afghanistan B-J
----------------------- copy starting from the next line -----------------------
------------------ copy up to and including the previous line ------------------
Listed 100 out of 495 observations
Use the count() option to list more
After cleaning, I wish to rehape the data with each Reporting country (Austria, Bahrain etc), i.e. source of FDI, in wide form; year and recipient country; i.e. Afghanistan in this case in long form. I will be thankful for some suggestion on reshaping and especially if through a loop/syntax where I import the each excel sheet, reshape and finally append the data by host country in a single .dta file?
Kind regards
I have numerous countries FDI data (1985-2022) with each couyntry in a seperate excel workbook named after respective country. When I import desired sheet from a given excel workbook for one country like Afghanistan the data looks like this
import excel "Afghanistan.xlsx", sheet("inflow-M") firstrow clear
dataex Afghanistan B-J
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str75 Afghanistan int(B C D E F G H I J) "FDI flows in the host economy, by geographical origin" . . . . . . . . . "" . . . . . . . . . "(Millions of US dollars)" . . . . . . . . . "" . . . . . . . . . "Reporting Country" 1985 1986 1987 1988 1989 1990 1991 1992 1993 "Austria" 0 0 0 0 0 0 0 0 0 "Bahrain" 0 0 0 0 0 0 0 0 0 "China" 0 0 0 0 0 0 0 0 0 "Croatia" 0 0 0 0 0 0 0 0 0 "Denmark" 0 0 0 0 0 0 0 0 0 "Finland" 0 0 0 0 0 0 0 0 0 "France" 0 0 0 0 0 0 0 0 0 "Germany" 0 0 0 0 0 0 0 0 0 "Greece" 0 0 0 0 0 0 0 0 0 "Hungary" 0 0 0 0 0 0 0 0 0 "India" 0 0 0 0 0 0 0 0 0 "Italy" 0 0 0 0 0 0 0 0 0 "Kazakhstan" 0 0 0 0 0 0 0 0 0 "Korea, Republic of" 0 0 0 0 0 0 0 0 0 "Latvia" 0 0 0 0 0 0 0 0 0 "Luxembourg" 0 0 0 0 0 0 0 0 0 "Netherlands" 0 0 0 0 0 0 0 0 0 "Norway" 0 0 0 0 0 0 0 0 0 "Poland" 0 0 0 0 0 0 0 0 0 "Russian Federation" 0 0 0 0 0 0 0 0 0 "Spain" 0 0 0 0 0 0 0 0 0 "Sweden" 0 0 0 0 0 0 0 0 0 "Switzerland" 0 0 0 0 0 0 0 0 0 "Thailand" 0 0 0 0 0 0 0 0 0 "Türkiye" 0 0 0 0 0 0 0 0 0 "United Kingdom" 0 0 0 0 0 0 0 0 0 "United States" 0 0 0 0 0 0 0 0 0 "" . . . . . . . . . "Source: UNCTAD, FDI/MNE database." . . . . . . . . . "Note: Data are based on information reported by the economies listed above." . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . "" . . . . . . . . . end
Listed 100 out of 495 observations
Use the count() option to list more
After cleaning, I wish to rehape the data with each Reporting country (Austria, Bahrain etc), i.e. source of FDI, in wide form; year and recipient country; i.e. Afghanistan in this case in long form. I will be thankful for some suggestion on reshaping and especially if through a loop/syntax where I import the each excel sheet, reshape and finally append the data by host country in a single .dta file?
Kind regards
Comment