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: