BookmarkSubscribeRSS Feed
Ronein
Onyx | Level 15

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

 

 

2 REPLIES 2
PaigeMiller
Diamond | Level 26

You could use the %DIRLISTWIN macro to read the file names and file dates.

 

http://support.sas.com/kb/24/820.html

--
Paige Miller
ChrisNZ
Tourmaline | Level 20

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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 870 views
  • 0 likes
  • 3 in conversation