From SAS to R

I worked for a few years with academics who insisted on using SAS. It was a new language for me but as I became more experienced, I grew to really enjoy using it. Since my transition to consultancy – sans available SAS license (FYI: it is expensive!) – I’ve set myself out to learn R.

After just one project, here are a few rambling thoughts I’ve had on R and SAS:

  1. RStudio helped me immensely in my transition into R. The setup is quite reminiscent of the SAS layout and being able to view my code, the console (where the code is executed), my datasets, the output and more in one window is a huge improvement over the basic R setup.
  2. Base R? Ok, yeah it’s good. But R packages are amazingly useful. The difficulty: which one do you need? I’ve found it’s really taken the guidance of experienced R users to find the most useful package for whatever task is at hand. Sometimes googling will help; there will always be a Stack Overflow thread to be found. But you might also find five different answers.
  3. Speaking of packages, the dplyr package that pipes a dataset through various functions strongly reminds me of data and proc statements in SAS. Before learning dplyr, I found modifying data in R to be much more laborious than in SAS. Now dplyr is one of my favourite packages.
  4. SAS has a lot of functions. Like a lot. And because they’re all written and managed by the company, syntax across functions is usually quite consistent. Given that R packages are user written, syntax can sometimes seem a little wonky. However, while SAS syntax is reliably consistent, updates and new functions are not regularly available; whereas that funny R package might soon be improved and new ones are always appearing.
  5. Graphics produced with ggplot2 (yes, another package) are far more sophisticated than anything I managed to create in SAS. Bonus: it took me about an hour to learn the basics of ggplot2 (incidentally, basic ggplot2 graphics are fabulous) whereas anything more than basic (and super boring) graphics in SAS still seem somewhat opaque to me.
  6. RMarkdown, available to use with Rstudio, can be used to produce complete documents, reports, etc., including figures and text, directly from your code. How cool is that? From SAS, I managed to output highly customized tables (requiring A LOT of coding) and decent graphics, but always needed to insert text and finalize formatting post-export. Extra bonus: RMarkdown is super, duper simple.

I could go on, but my ramblings appear to be mutating (dplyr joke!) into a pro-R list. Oops. I’ll finish up by saying that I feel as though I’ve just scratched the surface of what I can do with R and I know I’ll have fun learning more every day.