BookmarkSubscribeRSS Feed
Calcite | Level 5
I looking at grabbing some files based the modification date and trying this with dirlistwin. How do I get dirlistwin to recognize the modification date. My goal is to grab files that are less than 5 day old.

Rhodochrosite | Level 12
You will need to modify the macro to get the date modified rather than the date created. Use the dir /? command to see the syntax you need to change for your version of windows. Then modify the first filename command in the macro.
Calcite | Level 5
Thanks. I got the macro edited so that it will read the correct date. I want to incorporate the date filter and I don't want to hardcode the dates. Do you know a way to do something like this:

%dirlistwin (D:/temp/tmp/images,
MINDATE = "&sysdate."d - 5,
MAXDATE = "&sysdate."d

The directory that I'm checking has MANY files and I only want the files that are 5 days old.
Rhodochrosite | Level 12
In the macro world you will have to force the conversion of the data constant.
One way to do this is with the PUTN function.
[pre]%macro test(now, then);
%put now &now;
%put then &then;
%mend test;
%test(%sysfunc(putn("&sysdate"d,6.)), %eval(%sysfunc(putn("&sysdate"d,6.))-5))
Fluorite | Level 6
Just as an aside: using %sysevalf gives you the date value immediately.

%put %sysevalf("&sysdate"d) ;
%put %sysevalf("&sysdate"d+0) ;
%put %sysevalf("&sysdate"d-5) ;

When I want to edit the date value in macro logic I tend to use the intnx function like in
%let my_date = %sysfunc(intnx(day,"&sysdate"d,-5),ddmmyyp10.) ;
(where I know that syntactically the dot after the format name ain't needed)
Rhodochrosite | Level 12
Good suggestion on the use of %SYSEVALF. Much simpler.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 4 in conversation