Help using Base SAS procedures

PROC IMPORT - Problems with xls and xlsx

Reply
Contributor
Posts: 40

PROC IMPORT - Problems with xls and xlsx

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;

Contributor
Posts: 70

Re: PROC IMPORT - Problems with xls and xlsx

Hi..

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

Thanks,

Yaswanth

Contributor
Posts: 70

Re: PROC IMPORT - Problems with xls and xlsx

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;

Super Contributor
Posts: 418

Re: PROC IMPORT - Problems with xls and xlsx

Posted in reply to yaswanthj

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.

SAS Employee
Posts: 1

Re: PROC IMPORT - Problems with xls and xlsx

Try  DBMS=EXCELS instead of EXCEL and then try.

SAS/ACCESS(R) 9.2 Interface to PC Files: Reference, Second Edition

Occasional Contributor
Posts: 8

Re: PROC IMPORT - Problems with xls and xlsx

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

Super Contributor
Posts: 345

Re: PROC IMPORT - Problems with xls and xlsx

Posted in reply to JohannesLang

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

Ask a Question
Discussion stats
  • 6 replies
  • 2008 views
  • 0 likes
  • 6 in conversation