|
%let folder=D:\;
%let sysd=%sysfunc(today(),yymmddn8.);
%put &sysd;
options noxwait xsync;
x "dir/s &folder > &folder.dir.txt";
data readfile(drop=datestring);
infile "&folder.dir.txt" firstobs=8 missover;
input @1 date:yymmdd10. time &:time.
bytes :comma. filename :$200.;
format date yymmdd10. time time. bytes comma18.;
run;
x "erase &folder.dir.txt";
data file1;
set readfile;
length type $12.;
if date ne . and bytes ge 5;
type=scan(filename,-1,".");
if type eq 'xlsx';
type1=scan(filename,1,".");
if find(type1,compress(&sysd))>0;
run;
data file1;
set file1;
n=_n_;
run;
proc sql noprint;
select max(n) into :varno
from file1;
quit;
%put &varno;
%macro xlsx2sas();
%do i=1 %to &varno;
proc sql noprint;
select filename into :xlsxn
from file1
where n=&i
;quit;
%put &xlsxn;
%let route=%sysfunc(cats(&folder,\,&xlsxn));
%put &route;
proc import datafile="&route" out=xlsx&i. dbms=xlsx replace;run;
%end;
%mend;
%xlsx2sas;
|