<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/import-data-to-r-from-sas-spss-and-stata-with-haven/"></div></div><div><a data-url="https://www.r-bloggers.com/import-data-to-r-from-sas-spss-and-stata-with-haven/" data-counturl="https://www.r-bloggers.com/import-data-to-r-from-sas-spss-and-stata-with-haven/" data-count="horizontal" data-text="Import data to R from SAS, SPSS and Stata with Haven" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://blog.revolutionanalytics.com/2016/10/import-data-to-r-from-other-statistics-tools-with-haven.html"> Revolutions</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div>
<p>Regardless of the tool you use to analyse data, you'll often have to access data living in file formats generated by other tools. The &quot;haven&quot; package from RStudio  allows you to import and export data in SAS, SPSS and Stata formats. Version 1.0 was <a target="_blank" href="https://blog.rstudio.org/2016/10/04/haven-1-0-0/">released on October 4</a>, and is now <a target="_blank" href="https://mran.microsoft.com/package/haven/">available on CRAN</a>. Haven is also installed as part of the <a target="_blank" href="http://blog.revolutionanalytics.com/2016/09/tidyverse.html">tidyverse</a>.</p>
<p>Haven augments the <a target="_blank" href="https://news.ycombinator.com/item?id=12553367">base R foreign package</a> with additional formats. The core read/write engine is the <a target="_blank" href="https://github.com/WizardMac/ReadStat">ReadStat</a> package, and it provides support for:</p>
<ul>
<li>SAS binary files (SAS7BDAT), including compressed files</li>
<li>SPSS .sav and .por files</li>
<li>Stata files</li>
</ul>
<p>Haven takes special care in handling missing values in these file formats, and includes tools for extracting information from the specialized missing value representations in each format. It also has improved support for handling dates and times. (See the <a target="_blank" href="https://blog.rstudio.org/2016/10/04/haven-1-0-0/">blog post announcing Haven</a> for details.)</p>
<p>For those working in the pharmaceutical industry, there's one unfortunate omission in ReadStat (and therefore Haven) thus far. While the FDA does <strong>not</strong> mandate that SAS be used for analysis in clinical trials, it <a target="_blank" href="http://www.fda.gov/downloads/ForIndustry/DataStandards/StudyDataStandards/UCM384744.pdf">does mandate</a> that the data be provided in the SAS Transport File (XPORT) format, which is an <a target="_blank" href="http://support.sas.com/techsup/technote/ts140.pdf">open standard</a>. <a target="_blank" href="http://www.fda.gov/downloads/ForIndustry/DataStandards/StudyDataStandards/UCM384744.pdf">Hopefully</a> this will be added in a future release, but in the meantime you can read XPORT files with the <a target="_blank" href="https://www.rdocumentation.org/packages/foreign/versions/0.8-67/topics/read.xport">base read.xport function</a>, and write them with the <a target="_blank" href="https://mran.microsoft.com/package/SASxport/">SASxport package</a>.</p>
<p>For more information on Haven, check out the <a target="_blank" href="http://haven.tidyverse.org/index.html">Haven website</a>. Thanks to Hadley and the RStudio team for providing this useful functionality to R!</p>
<p> </p>
</div>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="https://www.r-bloggers.com/import-data-to-r-from-sas-spss-and-stata-with-haven/"></div></div><div><a data-url="https://www.r-bloggers.com/import-data-to-r-from-sas-spss-and-stata-with-haven/" data-counturl="https://www.r-bloggers.com/import-data-to-r-from-sas-spss-and-stata-with-haven/" data-count="vertical" data-text="Import data to R from SAS, SPSS and Stata with Haven" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://blog.revolutionanalytics.com/2016/10/import-data-to-r-from-other-statistics-tools-with-haven.html"> Revolutions</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/?s=Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/FODa3feKuzY"></a></div>