%let dirname = E:\CampaignRpt\biocam\leif\201810;
filename dirlist pipe "dir /B &dirname*.xlsx";
data dirlist_leif ;
length fname varying2560. reclen;
run;
data dirlist_leif;
set dirlist_leif;
call symput ('pvars',n);
run;
%put &pvars.;
data leif ;
format Campaign_code 50.
Group_Code 50.
SMS_Code 50.
Email_Address 50.
SMS_Sending_Time 50.
Email_Sending_Status 50.
Email_Click_Status 200.
Order_Time 50. ;
/varname $40./
stop;
run;
%macro getxlsx;
%do i=1 %to &pvars.;
data null;
set dirlist_leif;
if n=&i.;
call symput ('file',trim(fname));
run;
%put &file. ;
PROC IMPORT OUT= IMPORT
DATAFILE= "&dirname&file."
DBMS=EXCEL REPLACE;
SHEET="Sheet1$";
GETNAMES=YES;
MIXED=YES;
SCANTEXT=YES;
RUN;
data leif;
set leif
IMPORT
;
run;
%end;
%mend;
%getxlsx;