I need help. I am new to macros. I need to create a macro that will import multiple excel files base on a list of names. Below is my current code. Please help.
%let dte = FEB2019;/*update monthly*/
/*Identify the current months FL files FILEDATE*/
filename fref pipe "ls /unixfolder/*&dte.*.xlsx";
data work.file_curr;
infile fref;
input ;
file = scan(_infile_,-1,'/');
path=scan(_infile_,1,'.');
run;
/*List of current xls files to import*/
data file_a(keep=file );
set file_curr;
RUN;
/*Macro to import files*/
options mprint symbolgen mlogic;
%macro Imp(all_mth);
%let k=1;
%let mth = %scan(&all_mth, &k);
%do %while ("&mth" NE "");
proc import DATAFILE="/unixlocation/&mth."
dbms=xlsx
out=outdata replace;
run;
proc append base=outdata _ALL data=outdata FORCE;
run;
%let k = %eval(&k + 1);
%let mth = %scan(&all_mth, &k);
%end;
%mend;
data _null_;
length check $200.;
set file_a;
check = '%imp(file="strip(file));");
Please help!
... View more