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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 3920 views
  • 0 likes
  • 6 in conversation