Hi All I have about 1000 csv files I need to import into SAS from a folder. I found this macro on SAS communities to batch import them, however, it changes the name of the files to dsn1, dsn2, dsn3 etc. and I want to retain the file name as the dataset name in SAS. All the files are stock ticker names (i.e. AAPL.csv MSFT.csv etc.) and I want the imported dataset to be AAPL, MSFT etc. Here is the code: %macro drive(dir,ext); %local cnt filrf rc did memcnt name; %let cnt=0; %let filrf=mydir; %let rc=%sysfunc(filename(filrf,&dir)); %let did=%sysfunc(dopen(&filrf)); %if &did ne 0 %then %do; %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; %if %superq(ext) = %superq(name) %then %do; %let cnt=%eval(&cnt+1); %put %qsysfunc(dread(&did,&i)); proc import datafile="&dir\%qsysfunc(dread(&did,&i))" out=Dsn&cnt dbms=csv replace; run; %end; %end; %end; %end; %else %put &dir cannot be opened.; %let rc=%sysfunc(dclose(&did)); %mend drive; %drive(C:\path,csv); Any help would be appreciated!
... View more