批量导入excel

2018-10-30  本文已影响0人  寒微123

%let dirname = E:\CampaignRpt\biocam\leif\201810;
filename dirlist pipe "dir /B &dirname*.xlsx";

data dirlist_leif ;
length fname 2560; infile dirlist length=reclen; input fnamevarying2560. reclen;
run;

data dirlist_leif;
set dirlist_leif;
call symput ('pvars',n);
run;

%put &pvars.;

data leif ;
format Campaign_code 50. Customer_ID50.
Group_Code 50. Senddate50.
SMS_Code 50. EDM_Code50.
Email_Address 200. SMS_Sending_Status50.
SMS_Sending_Time 200. SMS_Reply50.
Email_Sending_Status 50. Email_Open_Status50.
Email_Click_Status 50. Email_Sending_Time200.
Order_Time 50. Order_Revenue50. ;
/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;

上一篇下一篇

猜你喜欢

热点阅读