Announcement

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

  • New package crosswalk-countries

    Do you have a dataset where countries are encoded using, say, ISO 3166 three-digit numeric codes, and you want to produce a table of EU member states as of, say, 1995—in, say, Chinese? This turns out to be quite easy with Ben Jann’s excellent crosswalk package and my own suite of crosswalk tables.

    Assuming the required packages are installed, here is an example of how this works. First, let me load some example data where countries are encoded using ISO 3166 three-digit numeric codes. The file kountry.dta from Raciborski’s kountry package provides exactly this.

    Code:
    . use _ISO3N_ using http://www.stata-journal.com/software/sj10-4/dm0038_1/kountry.dta, clear
    Now, using crosswalk with crosswalk-countries, we can generate two variables that record the year each country entered the EU and, where relevant, the year it exited:

    Code:
    . crosswalk join = cntry.iso3n_to_eu(_ISO3N_ 1)
    . crosswalk quit = cntry.iso3n_to_eu(_ISO3N_ 2)
    These variables allow us to create an indicator for EU membership in a given year. I’ll use 1995, as in the earlier example, but any other year could be used as well:

    Code:
    .  gen eu = join <= 1995 & quit > 1995
    Finally, we need to convert the numeric country codes into a string variable in Chinese. For this, we can again use crosswalk together with crosswalk-countries:

    Code:
    . crosswalk name = cntry.iso3n_to_name_zh(_ISO3N_)
    And here's the table:

    Code:
    . tab name if eu
    
                                       name |      Freq.     Percent        Cum.
    ----------------------------------------+-----------------------------------
                                       丹麦 |          1        6.67        6.67
                                     卢森堡 |          1        6.67       13.33
                 大不列颠及北爱尔兰联合王国 |          1        6.67       20.00
                                     奥地利 |          1        6.67       26.67
                                       希腊 |          1        6.67       33.33
                                       德国 |          1        6.67       40.00
                                     意大利 |          1        6.67       46.67
                                     比利时 |          1        6.67       53.33
                                       法国 |          1        6.67       60.00
                                     爱尔兰 |          1        6.67       66.67
                                       瑞典 |          1        6.67       73.33
                                       芬兰 |          1        6.67       80.00
                                   荷兰王国 |          1        6.67       86.67
                                     葡萄牙 |          1        6.67       93.33
                                     西班牙 |          1        6.67      100.00
    ----------------------------------------+-----------------------------------
                                      Total |         15      100.00
    You can use other languages (Arabic, English, German, French, Spanish, Russian) other organizations (African Union, International Court of Justice, OECD, etc.), geographical regions, and of course many other country coding systems.

    Installation of (most recent) crosswalk by Ben Jann:

    Code:
    . ssc install crosswalk
    Installation of crosswalk tables for countries is a bit more cumbersome since the number of files exceed the number of files Stata's package management can handle. I recommend:

    Code:
    . cd "`c(sysdir_personal)'"
    . net from https://gitup.uni-potsdam.de/ukohler/crosswalk-countries/-/raw/main/
    . net get crosswalk-countries
    . unzipfile crosswalk_countries_cwfcn.zip, replace
    This installs the package into the personal Ado directory. You may want to choose another directory if you don't want the package for your entire account.
    Last edited by Ulrich Kohler; 05 Dec 2025, 11:25. Reason: Crosswalk was updated on SSC. Installation from gitHub no longer necessary

  • #2
    I have just published V2.0 of crosswalk-countries on my GitLab-Site. The version adds some additional country coding system (e.g. FIPS), and some other country-related tables (e.g. phone numbers, time zones of the capital, currencies). Most importantly, the new version includes country names in some frequently spoken languages. The list of languages now comprises the following languages: Arabic, Bahasa Indonesia, Bengali, Chinese, Czech, Danish, Dutch, English, Estonian, Farsi, French, German, Greek, Hindi, Hungarian, Icelandic, Italian, Japanese, Lithuanian, Norwegian, Polish, Portuguese, Punjabi, Romanian, Russian, Slovak, Spanish, Thai, Ukrainian, Urdu.

    Installation:

    Code:
     . ssc install crosswalk
    . cd "`c(sysdir_personal)'"
    . net from https://gitup.uni-potsdam.de/ukohler/crosswalk-countries/-/raw/main/
    . net get crosswalk-countries
    . unzipfile crosswalk_countries_cwfcn.zip, replace
    Last edited by Ulrich Kohler; 08 Jan 2026, 10:06. Reason: corretion of line breaks in code

    Comment

    Working...
    X