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.

  1. In STATA, choose: 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.

  1. In SPSS, choose: 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.

  1. In R, choose: File > Open File
  2. Select the R file and click open
  3. Next, set the working directory (line 3), 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.

  1. In SAS, choose: 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.

Finding the Full Directory Path

Windows

Two ways to get the full directory path:

Navigate in the Windows File Explorer to the folder with your data files.

  • Click in the address bar and copy the directory path, or
  • Right-click on the .DAT file, choose properties, and then copy the location.

Mac

Two ways to get the full directory path:

Open Finder and select the folder with your data set files.

  • While the folder is selected, press command+i to open the Get Info window. Copy the directory path listed next to where, or
  • 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 >>