General Instructions for Opening an Extract on Your PC

The IPUMS NHIS extract builder provides raw ASCII data files and the command files necessary for reading the raw data into SPSS,Stata, and SAS. The extract system also allows users to request rectangular files in Stata, SAS, or SPSS format without needing to read in the raw ASCII data with a syntax file.

On the My Extracts page in My NHIS, we provide statistical package syntax files, a data file, and a codebook for each of your extract requests. To analyze data, you must first download the data and command file for your statistics package of choice. First, right click on the "data" link and select "Save Link As". Next, right click on the command file link of your choice and select "Save Link As".

All IPUMS datasets come compressed. There are many applications available for decompressing files. The links below direct you to some of the more popular shareware and freeware programs.

R Users

  1. Open RStudio and change your working directory to the location containing your ".dat" and ".xml" files manually or by typing:
    • setwd("C:\IPUMS\")
  2. If you haven't already installed the ipumsr package, install it with
    • install.packages('ipumsr')
  3. Then run the .R file downloaded from IPUMS to load your extract into R. Alternatively, you can load your extract manually with the following code.
    • library('ipumsr')
    • ddi <- read_ipums_ddi("nhis_00001.xml")
    • data <- read_ipums_micro(ddi)

  4. When R is finished reading the data, you will see an object named "data" in your global environment.

SPSS Users

  1. Unzip your data file.
  2. Open the SPSS command file in SPSS.
  3. Find the line at the top that reads:
    • cd ".".
    • If the ".dat" data file is on your C drive, for instance, you need to change that line to:
    • cd "C:\ihis_00001.dat".
  4. Click the "Run" menu and select "All". SPSS will then read in your data.

If you do not get any errors, but you do not see data in the data editor, click the "Transform" menu and select "Run Pending Transformations".

STATA Users

  1. Unzip your data file.
  2. Save the Stata ".do" command file in the same directory as you saved the ".dat" data file.
  3. Make sure Stata is pointing to the directory that contains the ".dat" data file and the ".do" command file. If these files are on your C drive, for instance, you should type:
    • cd "C:\"
  4. Execute the ".do" file. For example, if your .do file is named "extract_mail_com1.do", you will need to type:
    • do ihis_00001.do

You will see ‘end of do-file’ when STATA has finished reading in the data.

SAS Users

  1. Unzip your data file.
  2. Open the SAS command file in SAS.
  3. Change one line in your SAS command file to indicate the location of the ".dat" data file on your computer. If your AHTUS-X files are called ahtus_00001.sas and ahtus_00001.dat, then the line below the "AHTUS USER" notes in the ".sas" command file will read:
    • libname IPUMS ".";
  4. If the ".dat" data file is in a folder on your C drive, for instance, then you need to change that line to:
    • libname IPUMS "C:\";
  5. Click the "Run" menu and select "Submit." SAS will then read in your data.

Back to Top