Using Stata to generate text files as input to Hidalgo’s ProductSpaceParser.exe

Product space poster overlayed over a worldmap. (Hidalgo, et al. 2007)


The ProductSpaceParser.exe is written by Cesar Hidalgo that generates GML files of Product Space maps that network softwares (such as Cytoscape) can read. I will not explain what a product space is here. I assume that you already know what it is (else, here is the link), and you only want to know how to produce a product space map using your own data.

The ProductSpaceParser program and the instructions to use it are conveniently provided in the product space website. Now, suppose you want to create a product space for the Philippines for the years 2001 and 2008. Since the data is not availble from the website, I assume you have your data and have calculated the required revealed comparative advantage indices (RCA) and the only thing that is left to do is to draw the map. Here are the steps:
  1. Generate a tab-delimited text file with the format:

“ProductSITCCode” “CountryCode” YEAR RCA

where ProductSITCCode is the 4-digit SITC (Rev. 2) product code with leading zeros, CountryCode is a 3-letter code for the country (or city), YEAR is a 4-digit numeric year, and RCA is the numeric RCA index for the product.  This is easily done in Stata using the -outfile- command:

outfile ProductSITCCode CountryCode YEAR RCA using PHL.txt, wide nolabel [replace]

Notes: (1) The *.txt file should be saved in the folder where the productspaceparser.exe is. (2) The parser processes data for years 1975, 1980, and 1985-2000 only (unless this is already debugged). The trick is to recode the year (remember to take note of your changes!):

recode year (2001=1999) (2008=2000)
  1. Use the command prompt window (to bring out the command prompt window, type “cmd” in Run at the Start Menu) and feed the PHL.txt file into prductspaceparser.exe by typing the command line:

productspaceparser.exe PHL 1 PHL.txt

This command will return the GML files PHL_2000.gml and PHL_1999.gml (Also, unless the program has already been debugged, it will also create the GML files for the other years. Just ignore and delete these files). Now, you may rename your files to their correct years.

Note: You should be in the directory where the productspaceparser.exe is. You can go to the directory by using the change directory (cd) command in the command prompt. For example, if productspaceparser.exe is saved in the folder “D:\PRODUCTSPACE”, yuo must change the directory in the command prompt: If the default directory of your computer is: c:\folder, your window will look like:

C:\folder>
C:\folder>cd\ /to go to the root directory c/
C:\>
C:\>D:                                    /to go to the root directory d/
D:\>cd productspace\                 /to go to the folder productspace/
D:\PRODUCTSPACE>
D:\PRODUCTSPACE>productspaceparser.exe PHL 1 PHL.txt /to run productspaceparser.exe/
  1. You can now import the GML files to Cytoscape. It will draw the product space for you.

3 Responses

  1. hi, i’m trying to build a product space, but instead of use world trade data use national data. I can build de RCA.txt, but I am not sure about the other inputs in the zip from product space website.
    In specific, do you know what contains the “VerySpread” file? I just know that the first column is Product Code.
    And, is the proximity the third column of the “NetworkWithWeights” file between the two products of the first and second columns?
    At last, I’m not sure if the second column of the “WorldShareLog” file is the numerator or the PRODY.

    Please, could you help me or tell me were can I see this?

    I’m kind of desperate.

    thanks

  2. Thank you for adding the instruction on using the the command prompt. :)

Leave a Reply