BookmarkSubscribeRSS Feed
nickb
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.

Thanks,
Nick
5 REPLIES 5
Doc_Duke
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.
nickb
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,
OUT=work.temp,
REPORT=N,
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.
ArtC
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))
[/pre]
Robert_Bardos
Fluorite | Level 6
Just as an aside: using %sysevalf gives you the date value immediately.

Try
[pre]
%put %sysevalf("&sysdate"d) ;
%put %sysevalf("&sysdate"d+0) ;
%put %sysevalf("&sysdate"d-5) ;
[/pre]

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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1699 views
  • 0 likes
  • 4 in conversation