I have a sas7bdat data set of 2GB which i want to read in R. I am using sas7bdat package to read the dataset but after using read.sas7bdat,there is no response from R and it keeps on running for hours without any output.
I have tried using sas7bdat and haven package also. Can anyone help me read the data in R quickly.
Example
/* SAS */
libname rdata "C:/tmp";
data rdata.test;
input x y;
datalines;
5 6
7 8
;
run;
# R
setwd("C:/tmp")
# install.packages("haven")
library(haven)
test <- read_sas("test.sas7bdat")
The read_sas
function in the haven
package should be much faster than the sas7bdat
package's functions. As per Hadley's GitHub description:
Can read SAS's proprietary binary format (SAS7BDAT). The one other package on CRAN that does that, sas7bdat, was created to document the reverse-engineering effort. Thus its implementation is designed for experimentation, rather than efficiency. Haven is significantly faster and should also support a wider range of SAS files (including compressed), and works with SAS7BCAT files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With