IMPORT all excel files in a folder

Reply
Regular Contributor
Posts: 199

IMPORT all excel files in a folder

Hi,

Does anyone have code that will import all excel files (.xlsx) in a folder regardless of the name of the file?

All files have one sheet named ALL_INJ.

Also, is it possible to capture the name of the excel file in a macro or in each SAS dataset that is created?

Thank you.

Regular Contributor
Posts: 233

Re: IMPORT all excel files in a folder

Regular Contributor
Posts: 199

Re: IMPORT all excel files in a folder

Where can I find the code for the macro (ie %xls2sas)?

Thank you.

Regular Contributor
Posts: 233

Re: IMPORT all excel files in a folder

%macro xls2sas(folder=

,subfd=Y

,exclfd=

,startrow=);

You need to fill in those parameters.

Regular Contributor
Posts: 199

Re: IMPORT all excel files in a folder

Don't I need the SAS macro code in order to run the macro xls2sas?

Regular Contributor
Posts: 233

Re: IMPORT all excel files in a folder

%macro <macroname> is the beginning of the macro

%mend is the end of the macro

All that use in between %macro and %mend is the what you want the macro to run

/* first step of the macro xls2sas*/

%macro xls2sas(folder=

,subfd=Y

,exclfd=

,startrow=);

and %mend is where the macro for xls2sas ends

The next step is to call the macro and this is how you call it.

%xls2sas

(folder=

,subfd=Y

,exclfd=

,startrow=);

Did this help?

Regular Contributor
Posts: 199

Re: IMPORT all excel files in a folder

Isn't there macro code to download so the macro can be run?

For example:

http://www.sascommunity.org/mwiki/images/e/ee/For.sas

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