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

Hi, 

I'm trying to get an excel file in my SAS with the help of libname but it is giving error to me. I'm writing a sample code for reference.

libname A  '/folders/myshortcuts/SAS program/Passenger.xls';

 

I'm using SAS studio.

 

Please help me out in this

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

@Swati24 wrote:

Yes I'm using SAS Studio university Edition


In that case, you need to convert your Excel workbook to the xlsx format, as the Engines for the older xls files are only available on Windows (University Edition runs on a Linux virtual machine).

View solution in original post

9 REPLIES 9
Jagadishkatam
Amethyst | Level 16

Could you please give us more details which dataset you have used.

 

The approach of generating the excel file is incorrect in your case.

 

you can use the proc export procedure to generate the excel file.

 

an example is below

 

proc export 
  data=sashelp.prdsale 
  dbms=xlsx 
  outfile="c:\temp\prdsale.xlsx" 
  replace;
run;

source: https://blogs.sas.com/content/sasdummy/2012/01/25/export-to-excel-got-easier/
Thanks,
Jag
Swati24
Obsidian | Level 7

Thanks but the file which I have to import to my SAS Studio is passenger.xls. Proc Import is working fine but when I'm trying to use Libname statement it is giving error. 

Jagadishkatam
Amethyst | Level 16

So you are trying to import via libname statement, then please try the below

 

/* because Excel field names often have spaces */
options validvarname=any;
 
libname xl XLSX '/folders/myfolders/sample.xlsx';
 
/* read in one of the tables */
data sample;
  set xl.sample;
run;
 
libname xl CLEAR;
Thanks,
Jag
Swati24
Obsidian | Level 7

Thanks 

I tried but it is giving me error that xls engine not found

 

Swati24
Obsidian | Level 7

I'm using SAS Studio noy SAS 9.4 or 9.3

Swati24
Obsidian | Level 7

Yes I'm using SAS Studio university Edition

Kurt_Bremser
Super User

@Swati24 wrote:

Yes I'm using SAS Studio university Edition


In that case, you need to convert your Excel workbook to the xlsx format, as the Engines for the older xls files are only available on Windows (University Edition runs on a Linux virtual machine).

Swati24
Obsidian | Level 7

Ok Thanks for the solution

SAS Innovate 2025: Register Now

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!

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
  • 9 replies
  • 2049 views
  • 5 likes
  • 3 in conversation