How do I use a Stata data file in SAS?

1. Reading a Stata file up to version 9 with SAS

SAS 9.1.3 currently supports Stata up to version 9 via proc import.  The following example shows how to use SAS proc import to read in a Stata data file hsb2.dta.  It is advisable to check the log file and use proc contents to ensure the data have been read correctly. Notice that SAS recognizes the file type to be imported by file extension.

proc import out= hsb2 datafile = "c:\data\hsb2.dta";
proc contents data=hsb2;

2. Saving a Stata data file as a version 9 file

It is easy to save a data file as a version 9 file with the saveold command.  The saveold command in Stata 10 saves a Stata version 10 data file as a Stata version 9 file.  Here is an example.

use, clear
(highschool and beyond (200 cases)) saveold "c:\data\hsb2old.dta" file c:\data\hsb2old.dta saved

3. Using Stat/Transfer

The most updated version of Stat/Transfer will recognize Stata 10 files and converting Stata data files to SAS is fairly straightforward.

How to cite this page

Report an error on this page or leave a comment

The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California.