Hello
Let's say that there are multiple txt files with different dates.
For example:
A181127.TXT
A181128.TXT
A181129.TXT
A181130.TXT
The task is to tell SAS to import one file only that will be the file with last date.
How can I do it please?
One option is to find the last file by its file name which has date.
Other option is to find the last file by the date it was created (Import the file that was created last)
Joe
You could use the %DIRLISTWIN macro to read the file names and file dates.
http://support.sas.com/kb/24/820.html
This macro has a few limitations such as requiring pipe access, expecting an English language OS, and expecting AM PM times rather than a 24 hour clock.
If that's not your setup, a much more usable (but less feature-rich) macro is provided here by @BrunoMueller. Still for Windows only though.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.