Indiana University
University Information Technology Services
What are archived documents?

Login is for authorized groups (e.g., UITS, OVPIT, and TCC) that need access to specialized Knowledge Base documents. Otherwise, simply use the Knowledge Base without logging in.


How do I import SPSS, Stata, or SAS data files in R?

To import SPSS, Stata, or SAS data files in R, first install and load the package foreign. The functions read.spss() , read.dta() , and read.xport() of the package foreign import SPSS, Stata, and SAS Transport data files, respectively.

Use the following syntax to import the three types of data files:

> spssdata <- read.spss("C:/temp/spssfile.sav") > statadata <- read.dta("C:/temp/statafile.dta") > sasdata <- read.xport("C:/temp/sasfile.xpt")

The three data files are saved as R objects, called spssdata, statadata, and sasdata. The data sets are stored in R's memory and can be called for statistical analysis during the current R session.

Note: R cannot import SAS permanent data set (.ssd or .sas7bdat) files. Use Stat/Transfer to convert SAS permanent data set files to other file formats and then import them to R. At Indiana University, the Stat/Transfer software is available on Quarry and the Windows Student Technology Center (STC) computers.

If you have questions about using statistical and mathematical software at Indiana University, email UITS Research Analytics (formerly known as the Stat/Math Center). Research Analytics is located on the IU Bloomington campus at Woodburn Hall 200, and is open for consultation by appointment Monday-Friday 9am-5pm. For more, visit Research Analytics on the web, or call 812-855-4724 (IUB) or 317-278-4740 (IUPUI).

This is document azuw in domain all.
Last modified on October 18, 2012.

I need help with a computing problem

  • Fill out this form to submit your issue to the UITS Support Center.
  • Please note that you must be affiliated with Indiana University to receive support.
  • All fields are required.

Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.

I have a comment for the Knowledge Base

  • Fill out this form to submit your comment to the IU Knowledge Base.
  • If you are affiliated with Indiana University and need help with a computing problem, please use the I need help with a computing problem section above, or contact your campus Support Center.