Hello lazy OS2 Rules,
Here are my 2 cents, I didn't use Excel file name as the import dataset name, because some file might start with numeric or contains space or longer than what SAS required, but you can always change what you want.
Cheer.
/***************************************************;
* Program: TestImportMultipleExcel.sas
* Programmer: Clement Chen, sdclement@gmail.com
* Date: 4/4/2009
****************************************************/;
options nomlogic mprint nosymbolgen;
%let indir=C:;
%let ftype=%str(*.xls);
%let idtext=%str(*.*);
filename dir pipe "command/c find /c /i %str(%"&idtext%") &indir\&ftype";
data fname;
infile dir truncover lrecl=256;
input fname0 $ 1-256;
length fname $256;
if fname0='' then delete;
fname0=compress(upcase(fname0),'-');
_len=length(scan(fname0,-1,':'))+1;
totlen=length(fname0) - _len;
fname=substr(fname0,1,totlen);
keep fname;
run;
proc sql noprint;
select put(count(*), 3.) into: TotalN
from fname;
select distinct(fname) into: fname1- :fname%left(&TotalN)
from fname;
quit;
%macro GetExcelFile();
%do i=1 %to &TotalN;
PROC IMPORT OUT= WORK.Excel&i
DATAFILE= "&&fname&i"
DBMS=EXCEL REPLACE;
GETNAMES=YES;
MIXED=NO;
SCANTEXT=YES;
USEDATE=YES;
SCANTIME=YES;
RUN;
%end;
%mend GetExcelFile;
%GetExcelFile();
Message was edited by: sdclement