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

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 2434 views
  • 0 likes
  • 4 in conversation