<scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8="crossorigin="anonymous"></script><!-- Font Awesome icons --><linkrel="stylesheet"href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0="crossorigin="anonymous">
<p>SPSS (Statistical Package for the Social Sciences) is probably the most well-known software package for statistical analysis. SPSS is easier to learn than R, because in SPSS you only have to click a menu to run parts of your analysis. Because of its user-friendliness, it is taught at universities and particularly useful for students who are new to statistics. From my experience, I would guess that pretty much all (bio)medical students know it at the time they graduate. SAS and Stata are comparable statistical packages popular in big industries.</p>
<ahref="#compared-to-r"class="anchor"></a>Compared to R</h2>
<p>As said, SPSS is easier to learn than R. But SPSS, SAS and Stata come with major downsides when comparing it with R:</p>
<ul>
<li>
<p><strong>R is highly modular.</strong></p>
<p>The <ahref="https://cran.r-project.org/web/packages/">official R network (CRAN)</a> features almost 14,000 packages at the time of writing, our <code>AMR</code> package being one of them. All these packages were peer-reviewed before publication. Aside from this official channel, there are also developers who choose not to submit to CRAN, but rather keep it on their own public repository, like GitLab or GitHub. So there may even be a lot more than 14,000 packages out there.</p>
<p>Bottom line is, you can really extend it yourself or ask somebody to do this for you. Take for example our <code>AMR</code> package. Among other things, it adds reliable reference data to R to help you with the data cleaning and analysis. SPSS, SAS and Stata will never know what a valid MIC value is or what the Gram stain of <em>E. coli</em> is. Or that all species of <em>Klebiella</em> are resistant to amoxicillin and that Floxapen<sup>®</sup> is a trade name of flucloxacillin. These facts and properties are often needed to clean existing data, which would be very inconvenient in a software package without reliable reference data. See below for a demonstration.</p>
<p>Because you write the syntax yourself, you can do anything you want. The flexibility in transforming, gathering, grouping, summarising and drawing plots is endless - with SPSS, SAS or Stata you are bound to their algorithms and styles. They may be a bit flexible, but you can probably never create that very specific publication-ready plot without using other (paid) software.</p>
<p><strong>R can be easily automated.</strong></p>
<p>Over the last years, <ahref="https://rmarkdown.rstudio.com/">R Markdown</a> has really made an interesting development. With R Markdown, you can very easily reproduce your reports, whether it’s to Word, Powerpoint, a website, a PDF document or just the raw data to Excel. I use this a lot to generate monthly reports automatically. Just write the code once and enjoy the automatically updated reports at any interval you like.</p>
<p>For an even more professional environment, you could create <ahref="https://shiny.rstudio.com/">Shiny apps</a>: live manipulation of data using a custom made website. The webdesign knowledge needed (JavaScript, CSS, HTML) is almost <em>zero</em>.</p>
<p>Many R users just ask questions on websites like <ahref="https://stackoverflow.com">StackOverflow.com</a>, the largest online community for programmers. At the time of writing, more than <ahref="https://stackoverflow.com/questions/tagged/r?sort=votes">275,000 R-related questions</a> have already been asked on this platform (which covers questions and answers for any programming language). In my own experience, most questions are answered within a couple of minutes.</p>
<p><strong>R understands any data type, including SPSS/SAS/Stata.</strong></p>
<p>And that’s not vice versa I’m afraid. You can import data from any source into R. As said, from SPSS/SAS/Stata (<ahref="https://haven.tidyverse.org/">link</a>), but also from Excel (<ahref="https://readxl.tidyverse.org/">link</a>), from flat files like CSV, TXT or TSV (<ahref="https://readr.tidyverse.org/">link</a>), or directly from databases or datawarehouses from anywhere on the world (<ahref="https://dbplyr.tidyverse.org/">link</a>). You can even scrape websites to download tables that are live on the internet (<ahref="https://github.com/hadley/rvest">link</a>).</p>
<p>And the best part - you can export from R to all data formats as well. So you can import an SPSS file, do your analysis neatly in R and export back to SPSS. Although you might omit that very last step.</p>
</li>
<li>
<p><strong>R is completely free and open-source.</strong></p>
<p>No strings attached. It was created and is being maintained by volunteers who believe that (data) science should be open and publicly available to everybody. SPSS, SAS and Stata are quite expensive. IBM SPSS Staticstics only comes with subscriptions nowadays, varying <ahref="https://www.ibm.com/products/spss-statistics/pricing">between USD 1,300 and USD 8,500</a> per computer <em>per year</em>. SAS Analytics Pro costs <ahref="https://www.sas.com/store/products-solutions/sas-analytics-pro/prodPERSANL.html">around USD 10,000</a> per computer. Stata also has a business model with subscription fees, varying <ahref="https://www.stata.com/order/new/bus/single-user-licenses/dl/">between USD 600 and USD 1,200</a> per computer per year, but lower prices come with a limitation of the number of variables you can work with.</p>
<p>If you are working at a midsized or small company, you can save it tens of thousands of dollars by using R instead of SPSS - gaining even more functions and flexibility. And all R enthousiasts can do as much PR as they want (like I do here), because nobody is officially associated with or affiliated by R. It is really free.</p>
</li>
</ul>
<p>If you sometimes write syntaxes in SPSS to run a complete analysis or to ‘automate’ some of your work, you should perhaps do this in R. You will notice that writing syntaxes in R is a lot more nifty and clever than in SPSS.</p>
<divclass="sourceCode"id="cb1"><preclass="sourceCode r"><codeclass="sourceCode r"><aclass="sourceLine"id="cb1-1"title="1"><spanclass="co"># not all values are valid MIC values:</span></a>
<p>To work with R, probably the best option is to use <ahref="https://www.rstudio.com/products/rstudio/">RStudio</a>. It is an open-source and free desktop environment which not only allows you to run R code, but also supports project management, version management, package management and convenient import menus to work with other data sources. You can also run <ahref="https://www.rstudio.com/products/rstudio/">RStudio Server</a>, which is nothing less than the complete RStudio software available as a website (e.g.in your corporate network or at home).</p>
<p>If you want named variables to be imported as factors so it resembles SPSS more, use <code><ahref="https://haven.tidyverse.org/reference/as_factor.html">as_factor()</a></code>.</p>
<divclass="sourceCode"id="cb3"><preclass="sourceCode r"><codeclass="sourceCode r"><aclass="sourceLine"id="cb3-1"title="1"><spanclass="co"># download and install the latest version:</span></a>
<divclass="sourceCode"id="cb4"><preclass="sourceCode r"><codeclass="sourceCode r"><aclass="sourceLine"id="cb4-1"title="1"><spanclass="co"># read any SPSS file based on file extension (best way):</span></a>
<divclass="sourceCode"id="cb5"><preclass="sourceCode r"><codeclass="sourceCode r"><aclass="sourceLine"id="cb5-1"title="1"><spanclass="co"># save as .sav file:</span></a>
<p>To export your R objects to the SAS file format:</p>
<divclass="sourceCode"id="cb7"><preclass="sourceCode r"><codeclass="sourceCode r"><aclass="sourceLine"id="cb7-1"title="1"><spanclass="co"># save as regular SAS file:</span></a>
<divclass="sourceCode"id="cb9"><preclass="sourceCode r"><codeclass="sourceCode r"><aclass="sourceLine"id="cb9-1"title="1"><spanclass="co"># save as .dta file, Stata version 14:</span></a>
<aclass="sourceLine"id="cb9-2"title="2"><spanclass="co"># (supports Stata v8 until v15 at the time of writing)</span></a>
<li><ahref="#spss-sas-stata">SPSS / SAS / Stata</a></li>
<li><ahref="#compared-to-r">Compared to R</a></li>
<li><ahref="#import-data-from-spsssasstata">Import data from SPSS/SAS/Stata</a></li>
</ul>
</div>
</div>
</div>
<footer><divclass="copyright">
<p>Developed by <ahref="https://www.rug.nl/staff/m.s.berends/">Matthijs S. Berends</a>, <ahref="https://www.rug.nl/staff/c.f.luz/">Christian F. Luz</a>, <ahref="https://www.rug.nl/staff/c.glasner/">Corinna Glasner</a>, <ahref="https://www.rug.nl/staff/a.w.friedrich/">Alex W. Friedrich</a>, <ahref="https://www.rug.nl/staff/b.sinha/">Bhanu N. M. Sinha</a>.</p>
</div>
<divclass="pkgdown">
<p>Site built with <ahref="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>