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 ?
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.
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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.