0

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.

1
  • 1
    Try with library(haven);read_sas("C:....") Commented Sep 14, 2016 at 18:22

2 Answers 2

3

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 use forward 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.

Sign up to request clarification or add additional context in comments.

Comments

2

Try using forward slashes:

x <- read.sas7bdat("C:/Users/petas/Desktop/airline.sas7bdat")

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.