Oriol Prat
Oriol Prat

Reputation: 1047

Error in the LIBNAME statement sas

I want to import a database of excel to SAS, I use the correct commands but SAS tells me the following errors:

ERROR: Connect: ERROR:Error in the LIBNAME statement sas

libname dir  'E:\SAS\sessio2\dades';
proc import out=dir.m
datafile="E:\SAS\sessio2\dades\matrimonios.xlsx"
DBMS=excel 
replace;
RANGE="Hoja1$A1:AJ54"; 
getnames=yes;
run; 

Upvotes: 1

Views: 7457

Answers (2)

Yick Leung
Yick Leung

Reputation: 1078

I'm not sure if it's your libname statement path that is incorrect or the version of your SAS. if you're using datafile= "path.xlsx", then try using DBMS=.xlsx as well.

If that doesn't work, perhaps try changing datafile= from .xlsx to .xls I'm not sure which version of SAS you have.

But in 9.1.3 it's better to use .xls If your excel file is in .xlsx, just open it and save as 2003 .xls version. Your code seems to work fine on my computer but that's using my own excel file.

libname dir  'C:\sasdata';
proc import out=dir.m
datafile="C:\sasdata\sfosch.xls"
DBMS=excel 
replace;
*RANGE="Hoja1$A1:AJ54"; 
getnames=yes;
run; 

Upvotes: 1

DomPazz
DomPazz

Reputation: 12465

As Yick says, the error is in your PROC IMPORT statement. Behind the scenes PROC IMPORT creates a LIBNMAE statement using the EXCEL engine.

Some things that might be wrong:

  • If your version is prior to 9.1.3, I don't think you cannot read the new xlsx format. Save the file in the old format and try again.
  • Make sure you have specified the proper file and path.
  • Make sure you have the range specified properly.
  • The Range statement can be hinky. Try specifying the SHEET= option instead.
  • Make sure you have ACCESS/PC Files licensed.

Upvotes: 2

Related Questions