DATA Step, Macro, Functions and more

can't get data from Excel file

Reply
Occasional Contributor
Posts: 8

can't get data from Excel file

I am using SAS University Edition. I tried to using below statment to access excel file

libname prod xlsx "/folders/myfolders/SAS/book1.xlsx";

Actually there is no error in log. But I can only see the prod libref is created but there is no way to access the data in the Excel file. 

 

I attach the book1 file, from sheet2 you can see the result from proc contents, there is connection, but can't read data. 

Super User
Posts: 3,101

Re: can't get data from Excel file

Occasional Contributor
Posts: 8

Re: can't get data from Excel file

Import is working. But I feel it works more like input, create new dataset. Not like libname create a link to file. 

Occasional Contributor
Posts: 8

Re: can't get data from Excel file

Sorry, I mean infile
Super User
Posts: 17,750

Re: can't get data from Excel file

How did you try and 'read' the file. Did that generate an error? Include your code and log. 

Occasional Contributor
Posts: 8

Re: can't get data from Excel file

 libname prod xlsx "/folders/myfolders/SAS/book1.xlsx";
Log
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
55
56 libname prod xlsx "/folders/myfolders/SAS/book1.xlsx";
NOTE: Libref PROD was successfully assigned as follows:
Engine: XLSX
Physical Name: /folders/myfolders/SAS/book1.xlsx
57
58 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
70
Super User
Posts: 17,750

Re: can't get data from Excel file

Did you try accessing the data with a data step? Post that code

Occasional Contributor
Posts: 8

Re: can't get data from Excel file

No, I can't. After I use libname, there have libref created, but it empty, there is no data.

Super User
Posts: 17,750

Re: can't get data from Excel file

How do you know it's empty? 

Did you try a data step? 

 

Data want;

set libname.'Sheet1$'n;

run;

Ask a Question
Discussion stats
  • 8 replies
  • 126 views
  • 0 likes
  • 3 in conversation