Hello everyone,
I'm currently writing a code to extract data from Eurostat by using the user-written tool getdata. I need to get the EMU convergence criterion bond yields for 5 countries/geographical areas: Euro area, Germany, Spain, Italy and Portugal, in monthly frequency between 1980 and 2020. So far, my code is the following:
getdata xt EUROSTAT, r(irt_lt_mcby_m/M.MCBY.EA+DE+ES+IT+PT) g(GEO country) time(DATE month) s(1980) e(2020) f(m) clear
However, in Stata I get the data in the following form:
country month M_MCBY
EA 1980-01 .
EA 1980-02 .
...
DE 1980-01 8.06
DE 1980-02 8.39
...
ES 1980-01 15.5
ES 1980-02 15.4
...
IT 1980-01 13.96
IT 1980-02 14.09
...
PT 1980-01 .
PT 1980-02 .
Instead of creating 5 different variables for each country, the program creates one variable called "country" that contains the 5 countries.
In order to export this dataset to Excel, I would like to reshapen the data in the following way:
month EA DE ES IT PT
1980-01 . 8.06 15.5 13.96 .
1980-02 . 8.39 15.4 14.09 .
.... ... ... ... ... ...
From the examples that I have seen I know that using reshape or double reshape should solve this problem, but in order to implement it, do I need to change the country codes to have a common prefix, like GEO_EA, GEO_DE, for example? Or could I change the initial getdata code in order to get the intended shape? Unfortunately the help file for the getdata tool could not clarify me on this subject.
I'm a new Stata user, and I know this should be a relatively easy task to perform, but I really need your help. Thank you advance for your attention!
Best regards,
Erica
I'm currently writing a code to extract data from Eurostat by using the user-written tool getdata. I need to get the EMU convergence criterion bond yields for 5 countries/geographical areas: Euro area, Germany, Spain, Italy and Portugal, in monthly frequency between 1980 and 2020. So far, my code is the following:
getdata xt EUROSTAT, r(irt_lt_mcby_m/M.MCBY.EA+DE+ES+IT+PT) g(GEO country) time(DATE month) s(1980) e(2020) f(m) clear
However, in Stata I get the data in the following form:
country month M_MCBY
EA 1980-01 .
EA 1980-02 .
...
DE 1980-01 8.06
DE 1980-02 8.39
...
ES 1980-01 15.5
ES 1980-02 15.4
...
IT 1980-01 13.96
IT 1980-02 14.09
...
PT 1980-01 .
PT 1980-02 .
Instead of creating 5 different variables for each country, the program creates one variable called "country" that contains the 5 countries.
In order to export this dataset to Excel, I would like to reshapen the data in the following way:
month EA DE ES IT PT
1980-01 . 8.06 15.5 13.96 .
1980-02 . 8.39 15.4 14.09 .
.... ... ... ... ... ...
From the examples that I have seen I know that using reshape or double reshape should solve this problem, but in order to implement it, do I need to change the country codes to have a common prefix, like GEO_EA, GEO_DE, for example? Or could I change the initial getdata code in order to get the intended shape? Unfortunately the help file for the getdata tool could not clarify me on this subject.
I'm a new Stata user, and I know this should be a relatively easy task to perform, but I really need your help. Thank you advance for your attention!
Best regards,
Erica
Comment