Trying to import an excel workbook from a shared drive (local file server) into SAS.
This is what I got so far with error - ERROR: Import unsuccessful. See SAS Log for details.
proc import out = test
datafile = "\\xxxx.xxx.xxxx.xx\shared\test.xlsx"
DBMS=CSV REPLACE;
GETNAMES=NO;
DATAROW=2;
run;
Appreciate the help.
@ywon111 wrote:
Trying to import an excel workbook from a shared drive (local file server) into SAS.
This is what I got so far with error - ERROR: Import unsuccessful. See SAS Log for details.
proc import out = test
datafile = "\\xxxx.xxx.xxxx.xx\shared\test.xlsx"
DBMS=CSV REPLACE;
GETNAMES=NO;
DATAROW=2;
run;
Appreciate the help.
Your import code says the file is CSV but the file name is xlsx. It is entirely possible that you source file is not actually CSV. In which case you are telling Import to attempt to read a simple text file structure that is not the same as in XLSX.
Can you open that source file in a simple text editor (NOT Excel) such as Notepad? If you do an do not see values separated by commas then the file is in a different format and you need to use the correct DBMS value.
Where is SAS installed, locally or on a server?
The path has to be relative to the SAS installation.
@ywon111 wrote:
Trying to import an excel workbook from a shared drive (local file server) into SAS.
This is what I got so far with error - ERROR: Import unsuccessful. See SAS Log for details.
proc import out = test
datafile = "\\xxxx.xxx.xxxx.xx\shared\test.xlsx"
DBMS=CSV REPLACE;
GETNAMES=NO;
DATAROW=2;
run;
Appreciate the help.
You'll have to make sure the server has access to the shared drive and know how to access it from there. Unfortunately that usually requires talking to your IT area to understand how it's set up. A drive you see on your desktop could be the M drive for example but it could be mapped to G on the server.
The other method, is if you can find the file in Servers Files and Folders Pane (SAS Studio) you can then right click it and find the path and use that.
If you're using SAS Base or EG there are similar methods to find the path.
Please run this:
%put &sysscp;
and post the log from it. This will reveal the operating system of your SAS server.
No, that's only a message from the Enterprise Guide to itself where to fetch the stylesheet for displaying the output. It is part of the ODS tagsets.sasreport13 statement.
I am interested in the result of the %put, on University Edition it looks like this:
73 %put &sysscp; LIN X64
This is what I get
11 ODS _ALL_ CLOSE;
12 OPTIONS DEV=PNG;
13 GOPTIONS XPIXELS=0 YPIXELS=0;
14 FILENAME EGSR TEMP;
15 ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
16 STYLE=HtmlBlue
17 STYLESHEET=(URL="file:///C:/Program%20Files/SASHome/SASEnterpriseGuide/7.1/Styles/HtmlBlue.css")
18 NOGTITLE
19 NOGFOOTNOTE
20 GPATH=&sasworklocation
21 ENCODING=UTF8
22 options(rolap="on")
This is only part of the log. Te whole log, when I run the %put via Enterprise Guide, is this:
1 ;*';*";*/;quit;run; 2 OPTIONS PAGENO=MIN; 3 %LET _CLIENTTASKLABEL='Programm (2)'; 4 %LET _CLIENTPROCESSFLOWNAME='Prozessfluss'; 5 %LET _CLIENTPROJECTPATH=''; 6 %LET _CLIENTPROJECTPATHHOST=''; 7 %LET _CLIENTPROJECTNAME=''; 8 %LET _SASPROGRAMFILE=''; 9 %LET _SASPROGRAMFILEHOST=''; 10 11 ODS _ALL_ CLOSE; 12 OPTIONS DEV=PNG; 13 GOPTIONS XPIXELS=0 YPIXELS=0; 14 ODS LISTING GPATH=&sasworklocation; 15 FILENAME EGSR TEMP; 16 ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR 17 STYLE=EGDefault 18 STYLESHEET=(URL="file:///C:/Program%20Files/SASHome/SASEnterpriseGuide/7.1/Styles/EGDefault.css") 19 NOGTITLE 20 NOGFOOTNOTE 21 GPATH=&sasworklocation 22 ENCODING=UTF8 23 options(rolap="on") 24 ; NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR 25 26 GOPTIONS ACCESSIBLE; 27 %put &sysscp; AIX 64 28 29 GOPTIONS NOACCESSIBLE; 30 %LET _CLIENTTASKLABEL=; 31 %LET _CLIENTPROCESSFLOWNAME=; 32 %LET _CLIENTPROJECTPATH=; 33 %LET _CLIENTPROJECTPATHHOST=; 34 %LET _CLIENTPROJECTNAME=; 35 %LET _SASPROGRAMFILE=; 36 %LET _SASPROGRAMFILEHOST=; 37 38 ;*';*";*/;quit;run; 39 ODS _ALL_ CLOSE; 40 41 42 QUIT; RUN; 43
So your SAS runs on a Linux server. Ask your SAS administrator if your network share is mounted on that server, and if yes, what the Linux path to it is.
Something like
/mnt/location
or
/shared/location
Note that all these start with a forward slash; this means that they are absolute path names starting at the system root. See https://en.wikipedia.org/wiki/Unix_filesystem for more information.
@ywon111 wrote:
Trying to import an excel workbook from a shared drive (local file server) into SAS.
This is what I got so far with error - ERROR: Import unsuccessful. See SAS Log for details.
proc import out = test
datafile = "\\xxxx.xxx.xxxx.xx\shared\test.xlsx"
DBMS=CSV REPLACE;
GETNAMES=NO;
DATAROW=2;
run;
Appreciate the help.
Your import code says the file is CSV but the file name is xlsx. It is entirely possible that you source file is not actually CSV. In which case you are telling Import to attempt to read a simple text file structure that is not the same as in XLSX.
Can you open that source file in a simple text editor (NOT Excel) such as Notepad? If you do an do not see values separated by commas then the file is in a different format and you need to use the correct DBMS value.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.