BookmarkSubscribeRSS Feed
nds5134
Calcite | Level 5

I am trying to take a semi-automated code to become fully automated. Currently we have .txt files dropped daily in a folder with the naming convention FILE1_DS1_20181212_20181212.txt, sometimes this last part of the name is a range such as FILE2_DS1_20181210_20181212.txt.  Currently, every morning when I run the code I change the macro variables to match the correct dates which are needed (i.e %LET FILEDTE1=20181210, %LET FILEDTE2=20181212) so the files read in correctly. 

 

Is there a way for SAS to automatically pull those date values from the .txt file name? The date variables are later used in imports and outputs. 

 

FYI for more information we have 100+ text files that have this naming convention which are processed daily. I'm trying to account for data drops that cover the weekend, and other reasons,such as holidays, that may cause a date range. 

 

Thank You!

 

2 REPLIES 2
Reeza
Super User
I'll describe the process.
1. Write a small program that scans a folder and pulls all filenames
2. Filter filenames for ones relevant to you
3. Determine which files need to be read
4. Read
5. Repeat

All of these steps have been asked and answered on here, and some are actually in the SAS macro appendix.

Good Luck!
nds5134
Calcite | Level 5

Thank You! I will give this a try and post the code if it works.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 2 replies
  • 784 views
  • 0 likes
  • 2 in conversation