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:
myDataFrame=read.sas7bdat(theDamnSasFile);
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.
0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.