BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Gick
Pyrite | Level 9
%macro import_files(BIO=);
/*1**/

data fichiers (keep=fichiers);
length fichiers $256;
fich=filename('fich',"&BIO.");
/* */
did=dopen('fich');
/* compt */
nb_fich=dnum(did);
do i=1 TO nb_fich;
fichiers=dread(did,i);
output;
end;
/* */
rc=dclose(did);
run;

/*2 */
proc sql;
select SUBSTR(fichiers, 1, INDEX(fichiers, '.') - 1) into :Labo_list separated by ' '
from fichiers;
quit;
%put &Labo_list.; /* log */

/*3 -*/
%do l = 1 %to %sysfunc(countw(&Labo_list.));
%let labo = %scan(&Labo_list., &l.);
%put &labo.;
proc import datafile="&BIO.\&labo." out=Labo&l.
dbms=XLSX replace;
run;
%end;


data BDD_labo;
set
%do i = 1 %to %sysfunc(countw(&Labo_list.));
Labo&i.
%end;
;
run;

%mend;

%import_files(BIO=C:\BIO);

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 15 replies
  • 3349 views
  • 0 likes
  • 5 in conversation