As I am someone who likes to add a ReadMe.txt to top folders or eventually creates a backup copy of a folder during development, below a bit a more robust code variant (adding some checks): /* create a data set with the name and path of all files in all folders */ %let date_RegEx=(19|20)\d{2}-(0[1-9]|1[012])-([012]\d|3[01]); filename flist pipe 'dir /s/b/a-d "c:\temp\*.txt"'; data flist; infile flist lrecl=500 truncover; input this_file $500.; attrib Folder_Name length=$40 Date_From Date_To format=yymmdd10. Source length=$40 ; /* remove all rows with folder names not complying with naming convention */ Folder_Name=scan(this_file,-2,'/\'); if prxmatch("/^&date_RegEx._&date_RegEx$/oi",strip(Folder_Name))<1 then delete; Source=scan(this_file,-1,'/\'); Date_From=input(scan(Folder_Name,1,'_'),yymmdd10.); Date_To=input(scan(Folder_Name,2,'_ '),yymmdd10.); run; filename flist clear; data alldata; set flist; infile dummy lrecl=1000 truncover filevar=this_file end=done; /* DONE set to 1 when last input record read */ do while(not done); /* Read all input records from the currently */ /* opened input file, write to alldata */ input string $1000.; output; end; run;
... View more