woo, first of all your initial code will not work. since you are talking about reading .xls files and you are mentioning csv in option...so you need two changes at first glance, change at two places, %drive(f:\woo\,xls); and dbms=xls; step2: you have to add logic to rename all xls file variable... /*you new code*/ /*i didn't add logic to rename but just made two changes*/ options mlogic mprint sybolgen; /*woo directory has two excel files) libname woo 'f:\woo'; %macro drive (dir,ext); %let filrf=mydir; %let rc=%sysfunc(filename (filrf,&dir)); %let did=%sysfunc(dopen(&filrf)); %let memcnt=%sysfunc(dnum(&did)); %do i=1 %to &memcnt; %let name=%qscan(%qsysfunc(dread(&did,&i)),-1,.); %if %qupcase(%qsysfunc(dread(&did,&i))) ne %qupcase(&name) %then %do; %let dslist=; %if (%superq(ext) ne and %qupcase (&name)=%qupcase(&ext)) or (%superq(ext)=and %superq(name)ne %then %do; %let file=%qsysfunc(dread(&did,&i)); %let dslist=&dslist %scan(&file,1,.); proc import datafile="&dir.%unquote(&file)" out=%scan(%unquote(&file),1,.) dbms=xls; guessingrows=100; getnames=yes; run; %end; %end; %end; %let rc=%sysfunc(dclose(&did)); %mend drive; %drive(f:\woo\,xls);
... View more