Ok, I set up a test folder with some test Access datafiles and executed my program. I found a couple mistakes in my code, which I corrected in my post above. The program "worked" to a point. It did loop throught the files very nicely, but the creation date was always missing. I put a Proc Print after the Proc Contents step, and it turns out that crdate and modate, although available in the Proc contents output, are always missing. Here is an example of the results: The SAS System 18:58 Wednesday, April 23, 2014 58 Obs LIBNAME MEMNAME CRDATE MODATE 26 THISACC Failure List . . 27 THISACC Graph Examples . . So, unfortunately, it looks like perhaps Proc Contents is not able to determine the crdate for an Access file. So, I tried the code posted by RW9. I did have to tweak it a bit to successfully read my piped dir data (varies with system settings). I also found I needed to use the option /tw, instead of /tc to get the dates I wanted. /tc gave me the date that I copied the files into my test folder not the original file date. filename mypipe pipe 'dir "C:\LocalData\AccessTest\*.mdb" /tw'; data use_date; attrib buffer format=$2000. file_last_written_date format=date9. file_last_written_time format=time5. am_pm format=$2. file_size format=$30. file_name format=$50.; infile mypipe truncover ; input buffer $2000.; if substr(buffer,1,5) in ("Volum","Direc") or index(buffer,"<DIR>")>0 or index(buffer,"Dir(s)")>0 or index(buffer,"File(s)")>0 then delete; /* Remove some extra info */ file_last_written_date=input(put(scan(compbl(buffer),1,' '),$10.),mmddyy10.); /* note dependant on system settings */ file_last_written_time=input(put(scan(compbl(buffer),2,' '),$5.),time5.); am_pm=scan(compbl(buffer),3,' '); file_size=scan(compbl(buffer),4,' '); file_name=trim(scan(compbl(buffer),5,' ')) ; if file_name = ' ' then delete ; run ; proc print data = use_date ; var file_name file_last_written_date ; run ; So, I changed my CALL SYMPUT step to create a macro variable for the crdate as well as the file name, and then you would change the Driver macro and your own Macro program to have two parameters. * read set of filenames that are now sorted and generate macro variables ; data work.use_date; set work.use_date end=EOF ; CALL SYMPUT('file' || trim(left(_n_)), trim(file_name) ) ; CALL SYMPUT('crdate' || trim(left(_n_)) , PUT(file_last_written_date,date7.)) ; if EOF then CALL SYMPUT('filecount', _n_) ; run; * this will give you macros file1, file2, etc. ; %put file count = &filecount ; %put file1 = &file1, crdate1 = &crdate1 ; ** NEW: Driver macro that will loop through list of files ; %macro LoopFiles ; %if &filecount > 0 %then %do ; %do i = 1 %to &filecount ; %check_new_date(&&file&i, &&crdate&i); *notice recursive macro syntax - resolve &i then resolve &file1, etc..; %end ; %end ; %mend LoopFiles ; Your macro: %macro check_new_date(thisfile, thiscrdate); %if "&thiscrdate"d = %sysfunc(today()) %then %do; data _null_; abort return; run; %else %do; data check1; ..... %mend ; ** call driver macro ; %LoopFiles; Notice that I have used double-quotes around the date macro variable, and convert it from a text string to a SAS date with the "d' syntax. I hope that you will consider trying my driver macro approach, with the parsing of the piped filelist outside of (and above) your macro.
... View more