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


Hello,

I would like to import an excel file in sas (the estension of my file is .xlsx), but i don't know how to do it?

I would like to code it instead to use "file--> import data-->...".

I tried to use the procedure import but i don't get it.

Thanks.

Anaïs

1 ACCEPTED SOLUTION

Accepted Solutions
shivas
Pyrite | Level 9

Hi,

Try this..

PROC IMPORT OUT= WORK.input

            DATAFILE= "F:\test.xlsx"

            DBMS=EXCEL REPLACE;

     RANGE="Sheet$";

     GETNAMES=YES;

     MIXED=NO;

     SCANTEXT=YES;

     USEDATE=YES;

     SCANTIME=YES;

RUN;

Thanks,

Shiva

View solution in original post

9 REPLIES 9
shivas
Pyrite | Level 9

Hi,

Try this..

PROC IMPORT OUT= WORK.input

            DATAFILE= "F:\test.xlsx"

            DBMS=EXCEL REPLACE;

     RANGE="Sheet$";

     GETNAMES=YES;

     MIXED=NO;

     SCANTEXT=YES;

     USEDATE=YES;

     SCANTIME=YES;

RUN;

Thanks,

Shiva

anais
Calcite | Level 5

Thanks a lot Shiva.

I tried your codes, and I successfully get the excel file in the sas program!

Thanks,

Anaïs

OS2Rules
Obsidian | Level 7

Hi:

You know that if you use "file ---> import data ---> etc", you can save the code that was generated to load the file into SAS?

Then you just INCLUDE that code into you SAS session and save it - save you having to write the code in the first place.

anais
Calcite | Level 5

thanks for the information. I ignored that i could save the code when i used "file--> import data..".

Can-you explain me how to save the code generated to load the file into sas?

Thanks a lot,

Anaïs

Li
Calcite | Level 5 Li
Calcite | Level 5

Does this code works under SAS 9.3 Win7 64x machine? - Thanks. Li

anais
Calcite | Level 5

I don't know if it work under sas 9.3 Win7 64x machine.

I used the codes mentioned above on sas 9.3  32bit;

Anaïs

Li
Calcite | Level 5 Li
Calcite | Level 5

No, this will not work. I just tried. The log is:

ERROR: Connect: Class not registered

ERROR: Error in the LIBNAME statement.

art297
Opal | Level 21
SusanJ516_sas
SAS Employee

Hi Anais,

Sounds like you tried to use the documentation for PROC IMPORT but you "didn't get it."  I assume you were using the SAS/ACCESS Interface to PC Files, right?  

If you have feedback about the documentation that would help us improve it, please let me know.  Also, for the .xlsx format, there are a number of SAS Notes; just search on xlsx and import to see them.  Thanks,

Susan

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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