I changed a few things to Ksharp's answer and it worked for me: %let subdir=C:\path\; filename dir "&subdir.*.xlsx "; data new; length filename fname $ 200; infile dir eof=last filename=fname; input ; last: filename=fname; run; proc sort data=new nodupkey; by filename; run; data null; set new; call symputx(cats('filename',_n_),filename); call symputx(cats('dsn',_n_),compress(scan(filename,-2,'\.'), ,'ka')); call symputx('nobs',_n_); run; %put &nobs.; %macro import; %do i=1 %to &nobs; proc import datafile="&&filename&i" out=&&dsn&i dbms=excel replace; getnames=yes; mixed=yes; run; %end; %mend import; %import
... View more