peta sujith
peta sujith

Reputation: 1

Import SAS data file into R

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

Answers (2)

n1tk
n1tk

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

Upvotes: 3

gstats
gstats

Reputation: 131

Try using forward slashes:

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

Upvotes: 2

Related Questions