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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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