Stata, SPSS, R, and SAS
To import data into a statistical software package, you should have downloaded your custom dataset files from the NLS Investigator website. Instructions for the download process are located in the Download Options section of this user guide.
STATA
STATA users will use the .DCT or Dictionary file to import data, which is part of the basic download.
In STATA, choose:
- File > Import > Text data in fixed format with a dictionary
- Browse to find the .DCT file
- Select the file and click open, then click OK
Use the summarize command to see a table of descriptive statistics.
SPSS
SPSS users will use the syntax file to import data, which is part of the basic download.
In SPSS, choose:
- File > Open > Syntax.
- Select the syntax file and click open.
- Update the file handle on the first line to the complete directory path (on your computer) to the .DAT file.
- By default, the file handle reads:
file handle pcdat/name='filename.dat' /lrecl=36 - Once updated, it will have a detailed directory path similar to this example:
file handle pcdat/name='C:\Documents\sample-data\filename.dat' /lrecl=36
- By default, the file handle reads:
- Run all.
Once complete, the syntax editor will display a table of descriptive statistics and the data will be loaded in the statistical viewer (output window).
R
R users will use the R file to import data, which is part of the advanced download.
In R, choose:
- File > Open File.
- Select the R file and click open.
- Next, set the working directory (line 3). For example: setwd('C:/Documents/sample-data/')
- Note: Windows directory paths use \ (backward) slashes and R requires / (forward) slashes. If copy / pasting a Windows directory path, the slashes should be updated to avoid run time errors.
- Delete the # in front of the setwd() on line 3 before running the code.
- Click run at the top of the script file.
The console will display descriptive statistics once complete. To view a spreadsheet of the data, type: View(new_data) in the console window and click run.
SAS
SAS users will use the program file to import data, which is part of the basic download.
In SAS, choose:
- File > Open Program.
- Once the program is open, update the infile code with the full directory path.
- By default, the infile reads:
infile 'filename.dat' lrecl=21 missover DSD DLM=' ' print; - Once updated, it will have a detailed directory path similar to this example:
infile 'C:\Documents\sample-data\filename.dat' lrecl=21 missover DSD DLM=' ' print;
- By default, the infile reads:
- For users with SAS 9.3 or older, run the program as is.
- For those with version 9.4, delete the latter portion of the infile code before running the program.
- Example: infile 'C:\Documents\sample-data\filename.dat';
Once the program is complete, a table of descriptive statistics will appear.
Finding the full directory path
Windows
There are two ways to find the full directory path in Windows.
- Open File Explorer and navigate to the folder containing your data files.
- Then either:
- Click in the address bar and copy the folder path, or
- Right-click a data file, select Properties, and copy the path shown in the Location field.
Mac
There are two ways to find the full directory path on a Mac.
- Open Finder and navigate to the folder containing your data files.
- Then either:
- Select the folder and press Command + I to open Get Info, then copy the path shown next to Where, or
- Open Terminal and drag the folder into the Terminal window to display its full path.
Video tutorial
Watch our How to Import NLS Data into Statistical Software video for an import process demonstration.
Next: NLS Investigator Tutorial: NLSY97 demo
Previous: Account Features
Quick links: Table of Contents | Glossary of NLS Terms