READING EQUINOX FILES INTO STATA Statistical data files can be downloaded from Equinox in a number of different formats. This guide refers specifically to files downloaded in Stata format, and provides instructions using Stata 10.1, although the processes are likely very similar in other versions of the software. When a user downloads a Stata file from Equinox and extracts the compressed directory, three files should be present: a *.dat file containing the actual data; a *.do file that holds a program to be run within Stata software; and a *.html file that displays the search parameters in Equinox as they were entered by the user. Figure 1: Extracted data files downloaded from Equinox The following instructions outline the process required to read the *.do file into Stata so that the user may subsequently start using the data within the application. Step 1 Open the Stata software program When you first open the program, you will see a number of windows: The Command window is where you will be typing in commands to be executed; the Results window displays the results of each command; the Review window provides a history of the commands that have been entered in the current session; and the Variables window will list all variables within the data set once it has been read into the program. Figure 2: Stata software – initial screen upon load Maps, Data and Government Information Centre Trent University Library 12/2011 Software: Stata 10.1 1 Step 2 Increase memory allocation Stata allocates a specific amount of memory to data. In cases of larger data sets, this default value often isn't enough to read the entire data file. To increase the memory allocation, type the following command exactly as shown below into the Command window and press Enter: set mem 100m The Results window should read as shown in Figure 3 below. This increases the memory allocation to 100 MB, or 102400 KB. Figure 3: Stata Results window after increasing memory allocation Step 4 Edit DO File from Equinox The compressed directory downloaded from Equinox included a file with the *.do extension. This is essentially a code file that must be run in Stata before the data can be loaded and saved to Stata format. To do this, click the 'Window' menu and select 'Do-file Editor > New Do File'. Figure 4: Opening the Do-File Editor from the Window menu in Stata In the Do-File Editor, click 'File > Open' and browse to the location of your *.do file. Highlight the file and click 'Open'. The Do file should appear in the Do-File Editor window. Figure 5: A Do-file showing in Stata's Do-File Editor Maps, Data and Government Information Centre Trent University Library 12/2011 Software: Stata 10.1 2 You will be editing two lines within the file. The first line to edit is close to the top of the page, and will be the only line without a * in front of the text. The original line will read as follows: insheet using [path]\ftp44039.dat Change [path] to the full directory listing of the location of your Do file. For example, if your files are stored on the D drive in a folder called 'Workspace' and a subfolder called 'Stata', then the line should read as follows: insheet using D:\Workspace\Stata\ftp44039.dat Now scroll down to the last line in the file. This line will read: save [path\filename] Change this to the full directory listing of the location where you wish to save the new Stata file. We recommend saving the file to the same location as the originals, so to do this the line should read as shown below: save C:\Workspace\Stata\ftp44039 There is no need to specify a file extension; the file will be saved as a Stata file with the *.dta extension. Click the 'Save' icon in the Do-file Editor and then click 'Run' (shown below). When the process is complete, the Variables window should list all of the variables that exist within your data files. Close the Do-File Editor. Figure 6: Save and Run icons in the Do-File Editor If you wish, check the directory to ensure that the new Stata file has been created. You should see your original files plus a new file with the name you've provided and a *.dta extension. Figure 7: Directory showing original files and new Stata file with the .dta extension Maps, Data and Government Information Centre Trent University Library 12/2011 Software: Stata 10.1 3 Step 6 Load the data file to Stata Select 'File > Open' from the main menu in Stata. Browse to the location of the new *.dta file, highlight the file and click 'Open'. Figure 8: Opening the file in Stata The data file is now loaded and available for you to process. If you wish to view the observations, click 'Window > Data Editor' and a spreadsheet will open displaying the data, as shown below. Figure 9: Data Editor window in Stata Maps, Data and Government Information Centre Trent University Library 12/2011 Software: Stata 10.1 4
© Copyright 2024