BookmarkSubscribeRSS Feed
GuiVtzl
Fluorite | Level 6

Hello everyone,

I've got a little problem with my proc import. Indeed, when I use the code below, it doesn't enable me to import .xlsx files, but only .xls

How could I change it to import both ?

Thanks

Here's my code :

PROC IMPORT OUT=TRAVAIL.INPUTS_1_&Q&Y

            DATAFILE= "Y:\&Q&Y."

            DBMS=EXCEL REPLACE;

     RANGE="Sheet1$";

     GETNAMES=YES;

     MIXED=NO;

     SCANTEXT=YES;

     USEDATE=NO;

     SCANTIME=YES;

6 REPLIES 6
yaswanthj
Fluorite | Level 6

Hi..

Convert .xlsx (2007) file to .xls (2003), in your computer and use your code. you can easily import the files..

Thanks,

Yaswanth

yaswanthj
Fluorite | Level 6

Hi..

You can convert the .xlsx file to .csv and using infile statement, you can easily get into sas environment without using proc import procedure.

data test;

infile '"path/file.csv";

run;

Anotherdream
Quartz | Level 8

Along yaswanthj line of thinking, you could even write sas code to convert your Excel file to a csv without using an import, and then read in the csv file.

JohannesLang
Fluorite | Level 6

Hello GuiVtzl,

the values for the DBMS options that you can use depend on your SAS version (including the "bitness", i.e. if you have 32bit or 64bit SAS).

If you have SAS 9.3 64bit maintenance release 1 (TS1M0), you can use either DBMS=XLS or DBMS=XLSX, but you have to decide which Excel format you want to support, since they are quite different.

If thats not possible, you probably have to go the CSV way like the other commentators suggested.

regards,

Johannes

andreas_lds
Jade | Level 19

You can extract the file extension using %let fileExtension = %scan(&excelFile, -1, %str(.)) and use it afterwards in the dbms option.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 6 replies
  • 4578 views
  • 0 likes
  • 6 in conversation