<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/haven-1-0-0/"></div></div><div><a data-url="https://www.r-bloggers.com/haven-1-0-0/" data-counturl="https://www.r-bloggers.com/haven-1-0-0/" data-count="horizontal" data-text="haven 1.0.0" 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="https://blog.rstudio.org/2016/10/04/haven-1-0-0/"> RStudio Blog</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div>
<p>I’m pleased to announce the release of haven. Haven is designed to faciliate the transfer of data between R and SAS, SPSS, and Stata. It makes it easy to read SAS, SPSS, and Stata file formats in to R data frames, and makes it easy to save your R data frames in to SAS, SPSS, and Stata if you need to collaborate with others using closed source statistical software. Install haven by running:</p>
</div>
<pre><code><span>install.packages</span><span>(</span><span>&quot;haven&quot;</span><span>)</span></code></pre>
<p>haven 1.0.0 is a major release, and indicates that haven is now largely feature complete and has been tested on many real world datasets. There are four major changes in this version of haven:</p>
<ol>
<li>Improvements to the underlying ReadStat library</li>
<li>Better handling of “special” missing values</li>
<li>Improved date/time support</li>
<li>Support for other file metadata.</li>
</ol>
<p>There were also a whole bunch of other minor improvements and bug fixes: you can see the complete list in the <a target="_blank" href="http://haven.tidyverse.org/news/index.html#haven-1.0.0">release notes</a>.</p>
<div>
<h2>ReadStat</h2>
<p>Haven builds on top of the <a target="_blank" href="http://github.com/WizardMac/ReadStat/issues">ReadStat</a> C library by <a target="_blank" href="http://www.evanmiller.org/">Evan Miller</a>. This version of haven includes many improvements thanks to Evan’s hard work on ReadStat:</p>
<ul>
<li>Can read binary/Ross compressed SAS files.</li>
<li>Support for reading and writing Stata 14 data files.</li>
<li>New <code>write_sas()</code> allows you to write data frames out to <code>sas7bdat</code> files. This is still somewhat experimental.</li>
<li><code>read_por()</code> now actually works.</li>
<li>Many other bug fixes and minor improvements.</li>
</ul>
</div>
<div>
<h2>Missing values</h2>
<p>haven 1.0.0 includes comprehensive support for the “special” types of missing values found in SAS, SPSS, and Stata. All three tools provide a global “system missing value”, displayed as <code>.</code>. This is roughly equivalent to R’s <code>NA</code>, although neither Stata nor SAS propagate missingness in numeric comparisons (SAS treats the missing value as the smallest possible number and Stata treats it as the largest possible number).</p>
<p>Each tool also provides a mechanism for recording multiple types of missingness:</p>
<ul>
<li>Stata has “extended” missing values, <code>.A</code> through <code>.Z</code>.</li>
<li>SAS has “special” missing values, <code>.A</code> through <code>.Z</code> plus <code>._</code>.</li>
<li>SPSS has per-column “user” missing values. Each column can declare up to three distinct values or a range of values (plus one distinct value) that should be treated as missing.</li>
</ul>
<p>Stata and SAS only support tagged missing values for numeric columns. SPSS supports up to three distinct values for character columns. Generally, operations involving a user-missing type return a system missing value.</p>
<p>Haven models these missing values in two different ways:</p>
<ul>
<li>For SAS and Stata, haven provides <code>tagged_na()</code> which extend R’s regular <code>NA</code> to add a single character label.</li>
<li>For SPSS, haven provides <code>labelled_spss()</code> that also models user defined values and ranges.</li>
</ul>
<p>Use <code>zap_missing()</code> if you just want to convert to R’s regular <code>NA</code>s.</p>
<p>You can get more details in the <a target="_blank" href="http://haven.tidyverse.org/articles/semantics.html">semantics vignette</a>.</p>
</div>
<div>
<h2>Date/times</h2>
<p>Support for date/times has substantially improved:</p>
<ul>
<li><code>read_dta()</code> now recognises “%d” and custom date types.</li>
<li><code>read_sav()</code> now correctly recognises EDATE and JDATE formats as dates. Variables with format DATE, ADATE, EDATE, JDATE or SDATE are imported as <code>Date</code> variables instead of <code>POSIXct</code>.</li>
<li><code>write_dta()</code> and <code>write_sav()</code> support writing date/times.</li>
<li>Support for <code>hms()</code> has been moved into the <a target="_blank" href="https://github.com/rstats-db/hms">hms</a> package. Time varibles now have class <code>c(&quot;hms&quot;, &quot;difftime&quot;)</code> and a <code>units</code>attribute with value “secs”.</li>
</ul>
</div>
<div>
<h2>Other metadata</h2>
<p>Haven is slowly adding support for other types of metadata:</p>
<ul>
<li>Variable formats can be read and written. Similarly to to variable labels, formats are stored as an attribute on the vector. Use <code>zap_formats()</code> if you want to remove these attributes.</li>
<li>Added support for reading file “label” and “notes”. These are not currently printed, but are stored in the attributes if you need to access them.</li>
</ul>
</div>
<p> <a target="_blank" rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rstudioblog.wordpress.com/3297/"><img alt="" src="http://feeds.wordpress.com/1.0/comments/rstudioblog.wordpress.com/3297/" border="0"></a> <img alt="" src="https://i1.wp.com/pixel.wp.com/b.gif?resize=1%2C1&ssl=1" border="0" data-recalc-dims="1"></p>
<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/haven-1-0-0/"></div></div><div><a data-url="https://www.r-bloggers.com/haven-1-0-0/" data-counturl="https://www.r-bloggers.com/haven-1-0-0/" data-count="vertical" data-text="haven 1.0.0" 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="https://blog.rstudio.org/2016/10/04/haven-1-0-0/"> RStudio Blog</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/MG2O2nqBC-Y"></a></div>