2016-09-14 174 views
0

我想將SAS數據文件(sas7bdat格式)讀入R.我嘗試過使用sas7bdat軟件包,但最終出現錯誤。將SAS數據文件導入R

CODE:

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

錯誤:

'\U' used without hex digits in character string starting ""C:\U"

有人可以幫助我?提前致謝。

+0

嘗試'library(haven); read_sas(「C:....」)' – akrun

回答

1

嘗試使用正斜槓:

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

使用haven

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.

希望它可以幫助發佈例子。