Prepare Data
1. Download the dataset setup files from UC-UTCC Dataverse. Please follow UC-UTCC Dataverse user guide. Any question about UC-UTCC Dataverse, please contact Dataverse support email: rapeepong@dvn.utcc.ac.th
2. Please read and understand term of use before downloading each dataset. If you accept the term of use, make a checkbox “I agree and accept these terms of use” checked and click Continue button. Or not, click Cancel button.
3. Click Save button on the file download dialog box. And select the directory to save this file.
4. After downloading, you have to decompress the dataset setup files in your local computer. Figure 4 is just one of several ways to extract zip file in local computer. You can choose other solutions to extract file if you cannot follow this figure.
In Figure 4, we extract downloading file on the C drive.
5. Some dataset has a large size. So we have to separate the dataset into several parts. You don’t need to import all parts in Stata. Just import the interesting part to Stata for use.
For each part or dataset, there are many setup files and 1 ASCII data file. For Stata, we use only 3 files.
• A columnar ASCII data file (.txt)
• A Stata dictionary file (.dct)
• A Stata do-File (.do)
In Figure 5, we use these below files to import National Rural Development 2005 Part 1 (NRD2005 Part 1) to SAS. The path for reference is C:\NRD2005_setup_file\NRD2005_PART1
• NRD2005_PART1_DATA.txt
• NRD2005_PART1_setupSTATA.dct
• NRD2005_PART1_setupSTATA.do
Import data to Stata
1. Open Stata program.
2. Assign memory of RAM to Stata to receive and store the data by command
set mem allocation. Take look at Figure 6, we assign 500 megabytes of RAM to Stata.
3. To open Do-file editor, Click Window -> Do-file Editor -> New Do-file
4. Then Do-file Editor will open. To open Stata do-file or Stata dictionary file, click menu File -> Open. Then select directory that file is located.
Figure 8 Do-file Editor
Note: In this case, we will open 2 files of National Rural Development 2005 Part 1 (NRD2005 Part 1) that located in C:\NRD2005_setup_file\NRD2005_PART1
• NRD2005_PART1_setupSTATA.dct
• NRD2005_PART1_setupSTATA.do
5. The Do-file will display in the editor. Now we can check and edit code before running.
6. Enter the specification path of the file as below. It is important to import data to Stata. Please ensure that is correct path.
a. Stata dictionary file:
dictionary using – the raw ASCII data file.
In this case, we change the raw ASCII data file path from NRD2005_PART1_DATA.txt
to the correct path C:\NRD2005_setup_file\NRD2005_PART1\NRD2005_PART1_DATA.txt
on NRD2005_PART1_setupSTATA.dct (See Figure 10)
b. Stata Do-file:
infile using – the Stata dictionary file
In this case, we change the dictionary file path from NRD2005_PART1_setupSTATA.dct
to the correct path C:\NRD2005_setup_file\NRD2005_PART1\NRD2005_PART1_setupSTATA.dct
in NRD2005_PART1_setupSTATA.do (See Figure 11)
7. To save the modification, click menu File -> Save
Figure 12 Save file.
8. On Stata Do-File Editor, open the Stata do-file and import data by menu Tools -> Do
Figure 13 Import Data with Stata Do-File Editor.
9. After importing successfully, the dataset is ready for use in Stata.
Reference
http://www.icpsr.umich.edu/cocoon/SAMHDA/FAQ/0056.xml
http://www.icpsr.umich.edu/cocoon/SAMHDA/FAQ/0127.xml
Author: Sirivimol Thanchalatudom
Reviewer: Phongkiat Koopkan

