BookmarkSubscribeRSS Feed
KRusso
Obsidian | Level 7

Hello. I am working through the SAS Base Class and am trying to assign a library to an excel document. 

 

When I execute the code as directed in the tutorial, everything works swimmingly.

libname orionx pcfiles path="&path/Sales.xls";
run;

 

Then, I tried to apply it to my own data. The code runs without error. When I open the library, I see Sheet1$, Sheet2$ and Sheet3$.

But there is not data in any of the sets. Also, I receive an error that the table Lx."Sheet1$"n either does not exist or cannot be displayed. None of the tables have any observations. Any ideas? 


2009 libname lx pcfiles path="&path/TryingItOut.xlsx";
NOTE: Libref LX was successfully assigned as follows:
Engine: PCFILES
Physical Name: H:\UserData\Desktop\ecprg193\TryingItOut.xlsx
2010 run;

8 REPLIES 8
Haris
Lapis Lazuli | Level 10

In the current build of SAS 9.4, you can simply assign a libname <Name> Excel 'c:\folder\File.xlsx';  

 

Did you try not using PCFiles?

KRusso
Obsidian | Level 7
I receive this error:

libname lx excel "&path/TryingItOut.xlsx";
ERROR: Connect: Class not registered
ERROR: Error in the LIBNAME statement.
Haris
Lapis Lazuli | Level 10
Yeah, clearly, we're not working on the same versions of SAS. Give libname XLSX ''; a try...
Reeza
Super User

There may be something in the excel file that's causing issues. Try removing worksheets and having very simple excel sheets first. 

KRusso
Obsidian | Level 7

So the odd thing is that if I name the range, it works. Also, It appears that I can reference the datasets in the sheet, I just cannot view them.

Haris
Lapis Lazuli | Level 10
Make sure your Excel file is not open when you're running SAS! If Excel is open, SAS can't get access to the data therein.
KRusso
Obsidian | Level 7
After I've been trying it again, It appears via proc contents and proc print that the data is there. However, when I try to view in the explorer it does not display. So it's at least functional.
SASKiwi
PROC Star

If you haven't tried it try importing with: options validvarname = v7; to see if that helps.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 1534 views
  • 0 likes
  • 4 in conversation