Skip to content

How to import a SAS database into R (without SAS)

Info on this was unusually hard to find, mostly because of all the noise generated by tutorials to convert data from SAS to R while using SAS in the process (apparently SAS doesn’t make it that trivial to export a simple CSV file). This makes for an interesting read though, so if you feel like getting an interesting headache, be my guest.

If you just want to import a SAS file into R, without the need to own a copy of SAS, luckily someone eventually made a package for this, more specifically sas7bdat, by Matt Shotwell.

Very simple to use, syntax is just:

A life-saver, even though it reportedly doesn’t work with all SAS files: it still works with most (and it worked with mine ^^). Last but not least, it doesn’t even have dependencies, and is quite tiny (321 kB). Tested today on R 3.1.2. Note that it’s quite much slower than reading a CSV file, so maybe you’ll want to import your SAS file, and then save it as CSV if you plan to read it often in the future.

Posted in R (R-project), statistics.

0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Some HTML is OK

or, reply to this post via trackback.

Sorry about the CAPTCHA that requires JS. If you really don't want to enable JS and still want to comment, you can send me your comment via e-mail and I'll post it for you.

Please solve the CAPTCHA below in order to fight spamWordPress CAPTCHA