Hi,
you could use pipe to return the list of files in the path and filter the file names based on your variables for start and end:
data _null_;
call symputx('SD', put(intnx('day', today(), -60, 's'), yymmddn8.));
call symputx('ED' , put(intnx('day', today(), -1, 's'), yymmddn8.));
run;
%put &=SD.;
%put &=ED.;
%let path=C:\Temp\;
FILENAME pipedir pipe "dir ""%superq(path)\*.sas7bdat"" /b" lrecl=32767;
%*Import sas files;
DATA ds1;
length path filename $1000 ds $32;
infile pipedir truncover;
input filename $char1000.;
path="&path.";
ds=tranwrd(filename,'.sas7bdat','');
*keep files in range;
if "&SD."<=scan(ds,2,'_')<="&ED.";
RUN;
FILENAME pipedir clear;
*Set files;
DATA ds2;
set ds1 end=last;
by filename;
if _N_ eq 1 then do;
*Define library;
call execute('libname have "'||strip(path)||'" access=readonly;');
call execute('DATA want; SET ');
end;
call execute(' have.'||strip(ds));
if last then do;
call execute('; RUN; ');
call execute('libname have clear;');
end;
RUN;
*Clean up;
PROC DELETE lib=WORK data=ds1 ds2; RUN;
%symdel SD ED;
... View more