I need to pick the latest week file from a folder, but I don’t want to enter the week every time. It’s a weekly report which I want to make as easy as pressing F3 and having it run.
eg. sales_data_201123
sales_data_201124
and so on. In the above example, sales_data_201124 should be selected since it’s the latest one.
Please advise!
Rajans
There are a few ways you could approach this. One would be to look for a specific file — for example, use the
today()function combined withintnx()to calculate what is the name of the file you’re looking for and then open that file.I think an easier approach, however, would be to read all the file names in the directory into a data set:
Then just sort
fnamesand choose the last one, or better yet, useproc sqlto put the filename into a macro variable:The file you want to open can now be called with
&fname.