The following code examples demonstrate how to replicate selected results from NCHS publications such as Data Briefs, QuickStats, or National Health Statistics Reports.
Accessing the data sets
These code examples use the standard public-release NHANES datasets. The Continuous NHANES data (since 1999-2000) is released in SAS transport file (.xpt) format. SAS transport files can be imported into many software packages. See Module 1, Datasets and Documentation, for a detailed description of how the data files are organized.
The code examples include statements to download the required data files from the NHANES website and to import them into the software package for use.
Editing and running the code
You may need to edit some lines of the code in order to run it on your computer. For example, you may need to edit the path to a directory where you want to save a permanent dataset or the location where you have saved another piece of code provided by the tutorial. After you have downloaded a code example and opened it in the appropriate software program, search for comments with the keyword “TutorialUser” to identify lines of code that you will need to customize before you can run the code.
Software versions
Unless otherwise noted, the example programs use procedure syntax available in the following software versions:
- SAS-callable SUDAAN version 11
- SAS version 9.4 with SAS/STAT 14.1
- R version 3.5.2 with “survey” package version 3.35.1
- STATA/SE version 15
Review the documentation for the software version you are using to check for different capabilities or syntax changes.