Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Importing NLSY Data into Stata 1. Go to the NLSY website, http://www.nlsinfo.org/web-investigator/webgator.php. 2.

Select the NLSY79 cohort (unless you have a reason to select a different one). These are the people who have been followed since 1979. 3. Search for the variables you want, using the Word in title option. Finding variables in the NLSY is an art. If you want to know how much education a person has, you might try searching under education, schooling, and other similar words. As it turns out, the variables title is highest grade completed; searching for any one of those words would have given you what you wanted. Select the variables you want, and then repeat the search for any other variables that you want to add to the dataset. 4. Once youve selected all the variables you need, click extract variables. You want to extract as a Stata dictionary file, and you should probably get the codebook as well. (The codebook gives the exact wording of each question, and it explains how categorical variables are coded.) You may be asked to give your email address or to register with the NLSY. 5. The website will spend a few minutes generating the dataset. When its done, youll be able to download something that has a name like default49134864d740d_all.zip. When you unzip this, youll have a folder with a similar name. 6. You will find a bunch of files inside this folder. I would recommend doubleclicking on the do file to launch Stata (its the one with the .do extension). The do file is a program that tells Stata how to label your variables. Stata will give you an error message when it tries to run the program right now, but launching Stata from this file will set the directory where Stata looks for files. 7. After you get the error message in Stata, type clear. Youll need a good bit of memory to load the dataset. If you havent already, type set mem 50m, perm so that Stata will always set aside 50 megabytes of memory for your dataset.

8. At the top of your results window, you should be able to find a line like do
"/Users / swlt / Downloads / default-49134864d740d_all / default49134864d740d-value-labels.do" from when you tried run the program. Copy

the default-49134864d740d portion of this line. 9. To read your data into Stata,
type infile using default-

49134864d740d.dct (pasting in the name of your file).

Stata will need a few seconds or a few minutes to load the dataset. Once youre done, run the do file to attach the appropriate labels to things: do default-49134864d740d-valuelabels.do (or select this command from the top of your review window).

You might also like