BookmarkSubscribeRSS Feed
Kurt_Bremser
Super User

The fact that LIBNAME XLSX succeeds does not mean that the file actually exists, since LIBNAME XLSX can be used to create a new file. The Excel file will then only be written once data is written to this library.

To check if your account on the server has access to the shared resource (and that the file is actually there), run this first:

data _null_;
if fileexist('\\cala801nvs1.wellsfargo.com\C_RBGBBG_Users\galeanfr\My Documents\SAS\Campaigns.xlsx')
then put "Found";
else put "Not found";
run;

 

frankg80
Fluorite | Level 6

Thank you for your reply.  I ran the code and received this message below.  Why wouldnt the file be found?  How do I correct this so that SAS finds the file?  

 

41 data _null_;
42 if fileexist('\\cala801nvs1.wellsfargo.com\C_RBGBBG_Users\galeanfr\My Documents\SAS\Campaigns.xlsx')
43 then put "Found";
44 else put "Not found";
45 run;

Not found
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

SASKiwi
PROC Star

Where do your EG SAS sessions run? On a remote SAS server or locally on your PC (if you are using an EG connection profile then you have a remote SAS server)? If they are running on a remote SAS server then it is quite possible that it doesn't have the correct permissions to read your Excel file location. You would need to progress this with your SAS administrator.

frankg80
Fluorite | Level 6

I'm pretty new to this so please bear with me.  I am not sure whre my SAS session runs but I have connect to a profile which is on a different server (work server) I believe.  If I go to tools, connection, it brings up the Connections window and I have a profile name which states that it's on a work server from my job.  I don't know if that means it's a remote server...?

I tried disconnecting from that server and ran the Libname and I was able to access the excel file.  I even tried exporting the excel file and it also worked.  So I'm pretty sure it has to do with the fact that when I'm in the profile, then I cannot access the excel spreadsheet.  But when I'm off the profile (which means I'm not coneected to that server) then I can access the excel spreadsheet.   My question now is how can I connect to the xls spreadsheet while being ON  the server?  would I have to include some sort of path in the libname statement?  Or do I have to go to my SAS administrator to help me bypass that...  

Kurt_Bremser
Super User

When you say you were "off the profile", did you use the "Local" server to run your libname code that succeeded in downloading data from the Excel file?

frankg80
Fluorite | Level 6

I dont' know.  How can I check that?  

SASKiwi
PROC Star

@frankg80  - Using a connection profile means you are using a remote SAS server so only your SAS administrator can sort out access for you.

 

If you paste your file path into Windows Explorer on your PC does it work? I would guess that has to be yes if you say you can access the spreadsheet when you are "off the profile". I'm guessing that you also have a local SAS server on your PC as that is the only way EG will work if you are not using a connection profile. 

frankg80
Fluorite | Level 6

@Kurt_Bremser wrote:

Have you ever been able to access this file from any platform (e. g. opening it with Excel from your desktop)?


No, this is my first time using SAS and trying to access the xls document.  Please see my response to SASKiwi.

Tom
Super User Tom
Super User

Make sure that your SAS session can actually see the same file as you are looking. You might also want to make sure that you don't have the file open somewhere else that is preventing SAS from getting access.  Note that the LIBNAME will work if the file does not exists since at the point SAS does not know that you want to read from the file and not create a new file.

 

If you are sure the file is actually there then try this method to see what sheets are in it.

https://communities.sas.com/t5/SAS-Programming/How-to-import-second-sheet-from-Excel-workbook-in-to-...

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 24 replies
  • 3373 views
  • 3 likes
  • 7 in conversation