Reputation: 1
I want to read in a SAS data file (sas7bdat format) into R. I've tried using sas7bdat package, but ended up getting error.
CODE:
x <- read.sas7bdat("C:\Users\petas\Desktop\airline.sas7bdat")
ERROR:
'\U' used without hex digits in character string starting ""C:\U"
Can someone help me with this? Thanks in advance.
Upvotes: 0
Views: 5382
Reputation: 2490
Posting example by using haven
library
install.packages("haven")
library(haven)
url <- "C:\\Users\\petas\\Desktop\\airline.sas7bdat"
x <- read_sas(url)
If you use windows than you need to use instead
"\"
use"\\"
or Unix/linux style"/"
. Easiest will be to useforward slashes
so will be compatible in the future with the path of any OS, in your case Error:'\U' used without hex digits in character string starting ""C:\U"
is due the use of single backslashes instead double backslashes.
Hope it helps.
Upvotes: 3
Reputation: 131
Try using forward slashes:
x <- read.sas7bdat("C:/Users/petas/Desktop/airline.sas7bdat")
Upvotes: 2