Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to merge two data set with different country code?

    Hi, I have two data set. One from IMF and another from WB. Now the two institutions code country differently. How can I merge the data file from these two sources?

  • #2
    You need to create a crosswalk file that connects them. Perhaps one is already available somewhere on the internet. If not, you need to create one yourself. The file would contain (at least) two variables: the IMF code and the WB code. There should be precisely one observation for each country in the crosswalk file. Then you merge the IMF file on its country code with the crosswalk file. And then you merge that result on the WB code with the WB file.

    Comment


    • #3
      Originally posted by Clyde Schechter View Post
      You need to create a crosswalk file that connects them. Perhaps one is already available somewhere on the internet. If not, you need to create one yourself. The file would contain (at least) two variables: the IMF code and the WB code. There should be precisely one observation for each country in the crosswalk file. Then you merge the IMF file on its country code with the crosswalk file. And then you merge that result on the WB code with the WB file.
      Hi clyde, Thank you. But I do not know how create a crosswalk file to merge two separate file. Can you please give me any reference. Actually although the IMF file has country code, WB file do not have any country code. They only have country name. I did not succeed to merge file based on country and year because country name can not be edited. I do not exactly know how to convert country name (which is in string form in stata) so that they can be used for merging.

      Comment


      • #4
        Hi, kolpo: Please search and install kountry, and see the help file.
        Last edited by River Huang; 03 Mar 2018, 01:10.
        Ho-Chuan (River) Huang
        Stata 19.0, MP(4)

        Comment


        • #5
          Without seeing the actual data sets you are working with, it is hard to be sure just what country codes you have in the IMF set. Check out the file at https://www.imf.org/external/pubs/ft...eodata/co.xlsx. That spreadsheet contains in it first three columns something called IMF Code, the ISO code, and the country name. You should verify whether the IMF Codes in that file correspond correctly to the same countries as in the file you are working with. If so, I think you can start by just importing this spreadsheet into Stata (-help import excel- if you are not familiar with it) and keeping the IMF Code and Country name. (Probably you should keep the ISO Code as well, as this file may come in handy for other work later with data sets that rely on ISO coding.) Save it and keep it handy: this will probably be your crosswalk file.

          The other issue is then whether the country names in the WB file are matches to the names used in that spreadsheet. If they do, then the file created as described in the preceding paragraph is your crossswalk. If not, you need to edit the country names in your WB file. I know you said that you can't do that, but I can't imagine why not. Stata data sets are 100% editable in the Data Editor. So perhaps you could explain in more detail the problem you are having trying to edit those.

          I am not familiar with the -kountry- package that River Huang refers to, but a quick look at what comes up with -findit kountry- suggests that it may well solve your problem more easily than creating your own crosswalk file. So I would look into that as he suggests.

          Comment


          • #6
            Originally posted by River Huang View Post
            Hi, kolpo: Please search and install kountry, and see the help file.
            Hi,
            I was going through the same issue. I think you can use the following

            Code:
             kountry country_var , from(database_name | other) to(database_name)
            kountry country_var , from(imfn) to(iso3n)
            I would suggest using
            1. imfn (IMF) to iso3n(UN Stats)
            2. iso3c(WB) to iso3n(UN Stats)

            Comment


            • #7
              Anustup Kundu Thanks a lot.

              Comment

              Working...
              X