How do I use a SAS data file in Stata?

1. Using SAS software

If you are a SAS user and you need to use Stata for some analysis, for example, you can use proc export to convert your data to Stata format as shown below.  By specifying the file extension as .dta, SAS understands that the SAS data file mydata in the work directory will be converted to a Stata file. In the process of conversion, SAS will automatically convert the variable labels and value labels as well.

proc export data=mydata outfile= "C:\data\newdata3.dta";

2. Using Stat/Transfer

If you have Stat/Transfer, or have access to Stat/Transfer, converting SAS to Stata is fairly straightforward, if no conversion of value labels are involved.  If you need to convert value labels as well using a SAS format library and are using Stat/Transfer 10, you can click on the Options tab and select SAS Value Labels - Reading in the column on the left.  You can then use the drop-down menu that appears on the right to select the type of file that contains the value labels.  If you are using Stat/Transfer 9, you can click on the Options (3) tab, and the drop-down menu will be on the left of the screen. 

Note: If the file being transferred has more than 2,047 variables and you are going to use Stata/SE, the data file should be converted to Stata/SE, in which case you will need to select Output File Type: Stata/SE.

3. Using a SAS XPORT (*.xpt) file

Stata is able to read SAS XPORT data files (*.xpt) made with the XPORT engine using the fdause command such as in the example code below.  Here is the link to Stata's help file on fdause if you need more information.

fdause "C:\data\hsb2.xpt"

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.