Posted on 28 September 2010 by Mitch Abdon
Stata can be used interactively with your operating system — you can send commands to your operating system or open new programs within Stata. This is done using Stata’s shell commands.
In Using stata to generate textfiles as input to the product space, we introduced the program ProductSpaceParser.exe (Hidalgo, 2007) and showed how to generate the required text file using Stata’s -outfile- command. We also outlined the steps on how to execute ProductSpaceParser.exe using the command prompt window. Here, we will invoke ProductSpaceParser.exe inside Stata using the shell command -winexec-. The syntax for -winexec- is:
winexec program_name [program_args]
-winexec- is one of two shell commands for Windows or Mac (the other one is -shell- or -!-). It allows you to start other programs using Stata. To run ProductSpaceParser.exe from within Stata, change the directory to where the program is saved and execute the program (with the required program arguments: country ISO code, RCA cut-off, and text file name):
winexec ProductSpaceParser.exe PHL 1 PHL.txt
or you may type the complete path of the program:
winexec …\ProductSpaceParser.exe PHL 1 PHL.txt
The command above will generate the files PHL_yyyy.gml and save them to the current directory (see note below) . Now, you don’t need to get out of Stata after you have generated the required text files.
Note: The current directory is at the bottom-left of the Stata screen; or, you may display the current directory by typing:
Posted on 28 August 2010 by Mitch Abdon
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:
- 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)
- 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>cd\ /to go to the root directory c/
C:\>D: /to go to the root directory d/
D:\>cd productspace\ /to go to the folder productspace/
D:\PRODUCTSPACE>productspaceparser.exe PHL 1 PHL.txt /to run productspaceparser.exe/
- You can now import the GML files to Cytoscape. It will draw the product space for you.