BookmarkSubscribeRSS Feed
Ronein
Onyx | Level 15

Hello

I want to create export sas data set sashelp.cars into xlsx file.

I am using XLSX engine bia libname statement

libname RRR  xlsx "/usr/local/SAS/SASUsers/LabRet/UserDir/Udclk79/Targilim";
Data RRR.cars_XLSX;
set sashelp.cars;
Run;

Then I close SAS session and open again and run following code to import the data from XLSX file into SAS data set and I see that it is working 100% and indeed the XLSX file exist

libname RRR  xlsx "/usr/local/SAS/SASUsers/LabRet/UserDir/Udclk79/Targilim";
Data cars;
SET  RRR.cars_XLSX;
Run;

My question-

In SAS session I look at the library and I don't see the file that I created  cars_XLSX.

Porbably because it is not a sas  data set.

How can I see this file via SAS? 

Why I can see csv file but cant see xlsx file ?

Ronein_0-1738613285954.png

 

3 REPLIES 3
Tom
Super User Tom
Super User

Huh?   If you want to use the XLSX engine then it has to point to a FILE, not a directory.

 

If you want to use a file named cars.xlsx then say so in the libname statement.

libname RRR  xlsx "/usr/local/SAS/SASUsers/LabRet/UserDir/Udclk79/Targilim/cars.xlsx";

Your first code will work:

libname RRR  xlsx "/usr/local/SAS/SASUsers/LabRet/UserDir/Udclk79/Targilim";

As long as there is not already a directory named Targilim in the directory named /usr/local/SAS/SASUsers/LabRet/UserDir/Udclk79.  If there is a directory with that name you cannot then make a FILE with the same name.

 

But since you did not include the .xlsx extension on the file it will be hard to get Excel to open it.  You will probably need to use the File Open menu within Excel and it may well complain that the file extension does not match the content.

Ronein
Onyx | Level 15
Thanks.
I understand that it is not correct that I didn't add xlsx file name to the library path. However first code didn't give any error but I didn't see the cars_xlsx file.
Also in screen I see that data set cars_xlsx was created .
So as I understand sas ignored xlsx statement that I wrote in libref statement
libname RRR xlsx "/usr/local/SAS/SASUsers/LabRet/UserDir/Udclk79/Targilim";
Data RRR.cars_XLSX;
set sashelp.cars;
Run;
ballardw
Super User

SHOW the LOG for this code running in a new session (just in case you have other stuff that changed the library).

libname RRR xlsx "/usr/local/SAS/SASUsers/LabRet/UserDir/Udclk79/Targilim";
Data RRR.cars_XLSX;
set sashelp.cars;
Run; 

I strongly suspect the LOG will have something like (the d:\ is from my system)

Error creating XLSX file -> d:\. .  It is either not an Excel spreadsheet
or it is damaged.   Error code=80001002
Requested Output File is Invalid
ERROR: File RRR.cars_XLSX.DATA does not exist.

The existence of a file named cars_XLSX doesn't mean that it was created by the limited code you show. It might have been from another attempt, possibly a LIBNAME without the XLSX engine option.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 870 views
  • 0 likes
  • 3 in conversation