SAS and R: Data Management, Statistical Analysis, and Graphics (second edition)

Ken Kleinman and Nicholas J. Horton

Cover image

This book shows how equivalent statistical methods can be applied in either SAS or R, enabling users of each software package to learn how to apply the methods in the other. It covers data management, simple statistical procedures, modeling and regression, and graphics. Each section begins with a brief introduction to the procedures and then presents the code for each software side-by-side. The book provides detailed worked examples together with output from the software to illustrate how the methods are applied in practice. It also includes an index for both SAS and R, which will be useful to a wide range of users.

The first edition of this popular guide provided a path between SAS and R using an easy-to-understand, dictionary-like approach. Retaining the same accessible format, SAS and R: Data Management, Statistical Analysis, and Graphics, Second Edition explains how to easily perform an analytical task in both SAS and R, without having to navigate through the extensive, idiosyncratic, and sometimes unwieldy software documentation. The book covers many common tasks, such as data management, descriptive summaries, inferential procedures, regression analysis, and graphics, along with more complex applications.

New to the Second Edition

This edition now covers RStudio, a powerful and easy-to-use interface for R. It incorporates a number of additional topics, including using application program interfaces (APIs), accessing data through database management systems, using reproducible analysis tools, and statistical analysis with Markov chain Monte Carlo (MCMC) methods and finite mixture models. It also includes extended examples of simulations and many new examples.

Reviews of the First Edition

"As the authors point out in the Introduction, the book functions like an English-French dictionary. The material is organized by task. By looking up a particular task you wish to perform, R and SAS code are presented and briefly explained. ... If you use both SAS and R on a regular basis, get this book. If you know one of the packages and are learning the other, you may need more than this book, but get this book too." - Charles Heckler, Technometrics (2010).

"I am a long time SAS user who is surrounded by R experts. As such, I have been looking, for years, for a dictionary to translate between R and SAS. That is what this book is designed to do and it is absolutely excellent for this purpose. It covers all the SAS data manipulation and graphics procedures and functions that I use all the time and it shows how to do them in R. Happily the book is very up to date and the most modern (9.21) SAS graphics procedures (like sgplot) are covered. The organization and indexing are fantastic. There is a table of contents, an index with SAS vocabulary, an index of R vocabulary and an overall index. Using these tools you can quickly find the procedure/methods that you want to accomplish and get parallel code snippets in both languages along with annotation to say what the differences are between the two implementations. In addition to the pure dictionary organization there are extended examples working through the analysis and visualization of a large data set. This book is a must for people moving to R from SAS (or the other direction) and it should be excellent for people needing a dictionary to find functions/procedures to do data manipulation and graphic(s) tasks in either language." Amazon 5 star review

"For statisticians with knowledge of both SAS and R programming this book provides a useful resource to understand the differences between SAS and R codes and can be used for browsing and for finding particular SAS and R functions to perform common tasks. The book will strengthen the analytical abilities of relatively new users of either system by providing them with a concise reference manual and annotated examples executed in both packages. Professional analysts as well as statisticians, epidemiologists and others who are engaged in research or data analysis will find this book very useful. The book is comprehensive and covers an extensive list of statistical techniques from data management to graphics procedures, cross-referencing, indexing and good worked examples in SAS and R at the end of each chapter." - Significance (2010)

"... this book does exactly what it promises: it facilitates a translation between SAS and R, without getting overly detailed or technical. It is mainly useful as a starting point for those who already know either R or SAS, and want to learn the other language, without going over extensive manuals or introductory texts. " - Jeroen Ooms, Journal of Statistical Software (2011).

"This book is aimed at people with experience in one package wishing to transition to the other package. Having the code for both packages together in each section provides a very quick means for checking whether a planned analysis will be more straightforward in SAS or R. The authors have also written a book specific to SAS [1] and one specific to R [2]. These books cover mostly the same material as the ‘SAS and R’ book, with the package-specific books covering a few extra procedures. Anyone interested in only one of the packages would be advised to use the book specific to that package because the extra code in the ‘SAS and R’ book could be a distraction. ‘SAS and R’ provides good introductions to both packages in the appendices with many links to further documentation and tutorials. Readers new to either program would be well advised to work through the appropriate appendix for that package before reading the chapters but I believe the book would be quite challenging for a complete novice. More experienced users will be able to flip through to the section of interest without reading prior chapters and will find this book full of useful tips and tricks." - Robin Turner, Statistics in Medicine (2012)

See our blog for additional entries.

Last updated March 23, 2018