Sas2stata

Sas2stata is a Unix utility which converts SAS data sets into Stata format. It is a c-shell script which calls SAS to get content information on the data set, calls SAS to convert the SAS data set into ascii format; calls a number of standard Unix utilities to create a Stata dictionary file; and calls Stata to convert ascii data into a Stata data set.

Sas2stata may be downloaded as a tar file which contains all scripts and a Unix manual page. That manual page is also available in PDF format (14KB). Follow these steps to download sas2stata:

  • Download sas2stata.tar (49Kb) and store it on a Unix disk
  • Extract the files by typing "tar xfop sas2stata.tar" at the Unix prompt. This will create the following files:
    • README
    • sas2stata
    • Sas2stata/Scripts/put.awk
    • Sas2stata/Scripts/dct.awk
    • MAN/man1/sas2stata.1

The resulting README file contains further instructions. In addition to the files, sas2stata uses numerous Unix utilities (grep, sed, etc) which should all be readily available on your system. It also uses gawk, the GNU version of awk, which may or may not be installed on your system. The README file contains detailed instructions on how to obtain gawk (free of charge), should this be needed. For some machines, executables are available here:

NOTE: This version of Sas2stata has been modified to work correctly with Stata Version 8+. The prior version did not properly account for the special missing values introduced in that version, and may have inadvertantly converted some valid values to missings.

Please let RANDHRSHelp@rand.org know whether the installation was cumbersome, or how it may be improved. Any comments and suggestions on sas2stata itself are also welcome.

Sponsored by the RAND Center for the Study of Aging, with funds from the National Institute on Aging.