%macro import_files(BIO=);
%if %length(&BIO.) > 0 %then %do;
/* 1) */
filename filelist "&BIO.";
data filelist;
length filename $256;
rc = filename('dir', "&BIO.");
if rc = 0 then
did = dopen('dir');
if did > 0 then do while(dread(did) = 0);
filename = dread(did);
output;
end;
rc = dclose(did);
run;
/* 2) */
data _null_;
set filelist;
call symputx('filename', filename);
call symputx('filelist', ifc(length(filelist) > 0, "&filelist. " || filename, filename));
run;
%let filelist = %sysfunc(compbl(&filelist.));
%if %length(&filelist.) > 0 %then %do;
%let cnt = %sysfunc(countw(&filelist.));
/* 3) */
%do i = 1 %to &cnt.;
%let l = %scan(&filelist., &i.);
libname xlsx "&BIO.";
proc import datafile="&BIO.\&l." out=WORK.Labo&l.
dbms=XLSX replace;
getnames=yes;
run;
libname xlsx clear;
data BDD_labo;
set BDD_labo Labo&l.;
run;
%end;
%end;
%end;
%mend;
%import_files(BIO="C:/DATA/BIO");
Hi,
/* 1) retrieve the list of files in the folder configured in BIO 2) for each file, without sorting them according to their name, create a list containing the different names and do a do loop to automate the import of all files 3) each imported base is called Labo&l., and at the end of each import, add a data step to insert the results on the same base which will be called BDD_labo */ Can someone correct my code. I don't know why it doesn't work. No results and in the log, I get "NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release. Inserting white space" "WARNING: The quoted string currently being processed has become more than 262 characters long. You might have unbalanced quotation "
Another approach which allows the same steps to be carried out will be welcome.
Thanks in advance. Gick
... View more