View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

Be the first to rate this file! 3 Downloads (last 30 days) File Size: 28.5 KB File ID: #40033 Version: 1.0



Rex Cheung (view profile)


This NHANESCOPE program converts a SAS input program to a STATA do-file

| Watch this File

File Information

There is no easy way to convert a SAS file to a STATA file to input very large NHANES data files. This program can do that.

This program has been validated with public use (save as adult.txt by a free SAS viewer) and
adult.dat files. These files could be downloaded from NHANES III website by the public.

This program expects 1. the filename of a SAS file provided by NCHS NHANES, 2. the filenanme of a STATA 12 do-file, 3. the filename of a STATA do-file to store the formats and 4. the NHANES data file

Commands to run the script:
SASCodeFileName='adult.txt' STATADoFileName = 'stataadult1.txt'
STATADoFileName = 'stataadult1.txt' NHANESDataFileName = 'adult.dat'
NHANESCOPEConvertSASCodeToSTATACodeToReadNHANESDataFileSuccess = NHANESCOPEConvertSASCodeToSTATACodeToReadNHANESDataFile(SASCodeFileName,STATADoFileName, STATAFormatDOFileName, NHANESDataFileName)

This program has been tested without problems in STATA 12:

1. Make sure adult.dat is in the STATA working directory.
2. Load the stataadult1.txt, save as a do-file, run it, you will get 1238
%variables and 20050 records (rows)
3. Load the stataadultformat1.txt, save as a do-file, run it, you will
have all the variables formatted according to the formatting information
in the SAS file.

NOTE the STATA needs to load the data before it can format them

Required Products Statistics and Machine Learning Toolbox
MATLAB release MATLAB 7.14 (R2012a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.

Contact us