File Exchange

image thumbnail


version 1.0 (28.5 KB) by

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

1 Download


View License

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

Comments and Ratings (0)

MATLAB Release
MATLAB 7.14 (R2012a)

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

» Watch video