Chintan Shah
Chintan Shah

Reputation: 51

How can we read SAS data through readLines in R?

readLInes is giving error reading SAS data

readLines("C:/Users/shahch07/Desktop/364978/MEAP/Nig/2015/Prelim/Input/akure_city_res_design.sas7bdat")

 [1] ""    ")0" ")0" ")"   ""    ""    ""    ""    ""    ""   
[11] ""    ""    ""   
There were 12 warnings (use warnings() to see them)

Upvotes: 0

Views: 186

Answers (2)

yfyang
yfyang

Reputation: 220

Since SAS use a compressed binary format to store sas7bdat, you may need a package, sas7dat, to do it for you

  • sas7bdat: read.sas7bdat()

Notice, there are 32/64 platform differences.

Upvotes: 1

Thomas
Thomas

Reputation: 44585

You probably need to use a dedicated import function, such as:

f <- "C:/Users/shahch07/Desktop/364978/MEAP/Nig/2015/Prelim/Input/akure_city_res_design.sas7bdat"
haven::read_sas(f) # haven
rio::import(f)     # or, a more convenient wrapper around haven

Use install.packages(c("rio")) to install those packages.

Upvotes: 0

Related Questions