BookmarkSubscribeRSS Feed
katkarparam
Fluorite | Level 6

Read multiple file at a time? 

I have a piece of code. But it will read sheet one by one. i mean i have to call the macro with my particular sheet name. 

is there another way i can read all sheet at a time and create one dataset? 

 

%Macro  Due_Cal(sheet);

Proc import out= Due_date

    Datafile = 'E:\Bank Data Model\project bank\Loan_Congo_Banking.xls'

    Dbms = Excel;

    Sheet = "&sheet";

    Getnames = yes;

run;

%mend   Due_Cal;

 

% Due_Cal (Kinshasa);

5 REPLIES 5
Shmuel
Garnet | Level 18

Are all the sheets in the excel file the same format? 

Can you save your .xls file as .xlsx file?

What sas version do you use?

 

If your input was a .xlsx file and all your sheets the same format then you could use a code like:

libname myxl xlsx '<path and name>.xlsx';  

data want;
  set myxl.<sheet1_name>
      myxl.<sheet2_name>
     ...
 ; run;

 

katkarparam
Fluorite | Level 6

sas 9.2 .

windows platform.

microsoft excel 10.

 

i will try your methd and let u know sir..

Thnaks for the valuable time...

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Great advice, use the xlsx engine, but you must have SAS 9.4.  To note, you can simply copy so you don't need to type in each one:

libname myxl xlsx '<path and name>.xlsx'; 

proc copy in=myxl out=work;
run;

libname myxl clear;

Don't forget to clear the file ref afterwards.

katkarparam
Fluorite | Level 6
thanks...it works..
katkarparam
Fluorite | Level 6
thank u..sir..

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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