BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
marathoner
Fluorite | Level 6

I am trying to import an excel file from my desktop into my local SAS instance and I get this error:

ERROR: Physical file does not exist, /opt/sas/94/comp/config/Lev1/SASApp/C:\Users\Desktop\/test*.

I am getting this error because my machine does not recognize "C:\Users\Desktop\test*.xlsx" in SAS server. How can I point SAS to my local drive? I can't upload data the SAS server. I need my code to run locally.

proc import	
	out = report
	datafile = "C:\Users\Desktop\test*.xlsx"
	DBMS=xlsx 
    REPLACE;
    GETNAMES=YES;
RUN; 
1 ACCEPTED SOLUTION

Accepted Solutions
marathoner
Fluorite | Level 6

When you are connected to a server, you can point to a local address by the following this steps.

  • On the right hand corner of SAS EG, double click on the current SAS Server. 
  • The window below should pop up. Then select <do not use a profile> and click on [Set Active]
  • marathoner_0-1633451542203.png

 

 

 

This allow me to import an Excel file into my Work Library

 

proc import	
	out = report
	datafile = "C:\Users\Desktop\test*.xlsx"
	DBMS=xlsx 
    REPLACE;
    GETNAMES=YES;
RUN; 

 

View solution in original post

6 REPLIES 6
SASKiwi
PROC Star

Your SAS session is running on a remote SAS server. If you are using EG there is a Copy Files task to move files between your PC and your SAS server. Use this task to copy the spreadsheet to a SAS server folder prior to rerunning your program pointing at the server folder. 

Tom
Super User Tom
Super User

So you are not using SAS running on your local machine.  From the error message it is clear that SAS is actually running on a Unix machine.

 

How are you connecting to SAS?  Are you using SAS/Studio?  Enterprise Guide?  Something else?

 

Both of those should allow you to upload a file.  Even if you don't have your own space to write the file on the SAS server you should be able to upload the file into the WORK directory that your SAS session is using.  You can write there just like you can create a WORK dataset.

Patrick
Opal | Level 21

With SAS Studio and EG alternatively to uploading a file you can also use the import wizard. This wizard allows you to import your table from local (where SAS Studio and EG run) and the client applications will then upload the data to a SAS table on your server where SAS actually executes.

Kurt_Bremser
Super User

You are definitely not using a local SAS installation.

Your SAS is running on a remote UNIX (most probably Linux) server and has its configuration stored in

/opt/sas/94/comp/config

The remote session is started by

/opt/sas/94/comp/config/Lev1/SASApp/WorkspaceServer/WorkspaceServer.sh

and the script switches the current working directory to

/opt/sas/94/comp/config/Lev1/SASApp

and since your Windows path name is not recognized as an absolute path by UNIX, it is appended to the current working directory.

 

You also cannot import multiple Excel files with PROC IMPORT, you need to do it one at a time. Wildcards can be used when reading text files with a DATA step.

 

You must upload your data to the server with the upload facility of SAS Studio or the Copy Files task of Enterprise Guide, depending on the SAS interface you use. Then you can use the UNIX path in your code.

 

For SAS Studio, if you upload to the Files (Home) location, you only need to use

"~/test1.xlsx"

as the filename; the tilde is a shortcut for your personal home directory.

 

marathoner
Fluorite | Level 6

When you are connected to a server, you can point to a local address by the following this steps.

  • On the right hand corner of SAS EG, double click on the current SAS Server. 
  • The window below should pop up. Then select <do not use a profile> and click on [Set Active]
  • marathoner_0-1633451542203.png

 

 

 

This allow me to import an Excel file into my Work Library

 

proc import	
	out = report
	datafile = "C:\Users\Desktop\test*.xlsx"
	DBMS=xlsx 
    REPLACE;
    GETNAMES=YES;
RUN; 

 

Tom
Super User Tom
Super User

So you have now provided the information missing from your original question.

First that you are using SAS Enterprise Guide instead of running SAS directly.

Second that you actually have SAS installed on your local machine, but you had told Enterprise Guide to use a different instance of SAS when it submitted your code snippet.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 6 replies
  • 2466 views
  • 0 likes
  • 5 in conversation