Skip to main content

Importing Data

Stata, SPSS, R, and SAS

To import data into a statistical software package, users should have downloaded their custom data set files from the Investigator website. Instructions for the download process are located in the Save / Download Tab section of the Investigator 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:

  1. File > Import > Text data in fixed format with a dictionary
  2. Browse to find the .DCT file
  3. 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:

  1. File > Open > Syntax.
  2. Select the syntax file and click open.
  3. 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
  4. 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:

  1. File > Open File.
  2. Select the R file and click open.
  3. 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.
  4. Delete the # in front of the setwd() on line 3 before running the code.
  5. 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:

  1. File > Open Program.
  2. 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;
  3. For users with SAS 9.3 or older, run the program as is.
  4. 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.

Video tutorial

Watch our How to Import NLS Data into Statistical Software video for an import process demonstration.

Additional help

Finding the full directory path

Windows

There are two ways to get the full directory path in Windows. Start by navigating in the Windows File Explorer to the folder with your data files:

  1. Click in the address bar and copy the directory path, or
  2. Right-click on the .DAT file, choose properties, and then copy the location from the dialog window.

Mac

There are two ways to get the full directory path on a Mac. Start by opening the Finder and selecting the folder with your data set files:

  1. While the folder is selected, press Command+i to open the Get Info window. Copy the directory path listed next to where, or
  2. Open the Terminal and drag the folder into the Terminal window. This will output the full path of the folder.

Previous Table of Contents Glossary Next