I have a number of csv files in a folder. They all have the same structure (3 columns). The SAS code below imports all of them into one dataset. It includes the 3 columns plus their file name.
My challenge is that the filename variable includes the directories and drive letter (e.g. 'Z:\DIRECTORYA\DIRECTORYB\file1.csv'). How can I just list the file name and not the path (e.g. file1.csv)? Thank you
data WORK.mydata;
%let _EFIERR_ = 0; /* set the ERROR detection macro variable */
length FNAME $80.;
infile 'Z:\DIRECTORYA\DIRECTORYB\*2012*.csv' delimiter = ',' MISSOVER DSD lrecl=32767 filename=fname firstobs=2;
informat A $26. ;
informat B $6. ;
informat C 8. ;
format A $26. ;
format B $6. ;
format C 8. ;
input
A $
B $
C;
if _ERROR_ then call symputx('_EFIERR_',1);
filename=fname;
run;