Skip to content

NHANEStoMySQL

Tim Erickson edited this page May 15, 2019 · 7 revisions

The path from SAS transport files to CODAP

The NHANES site lets you download SAS transport files (.xpt). But for our system to use them, we need them in MySQL (or some other database that we will access from CODAP/JS).

SAS transport to CSV

Do this is RStudio. Here is example code:

open(tidyverse)
library(data.table)

bp <- read_xpt("BPX_I.xpt")
fwrite(bp, file="bp.csv")

CSV to MySQL

Using Sequel Pro, choose File\Import and select the .csv. Check that the column headings are correct; the most common mistake for me has been to fail to indicate that this is going to be a new table.

Additional munging

For the data to appear in the NHANES plugin, you also need to

  • Make sure whatever (new) variables you want to appear in the interface are identified in the varlist table.
  • Be sure that any values that need translating are listed (keyed by the internal variable name) in the decoder table.

Clone this wiki locally