BookmarkSubscribeRSS Feed
podarum
Quartz | Level 8

I have a daily symput address path that I get from another team, the only changes to this path is the current day.  For example the name of this path is ABC_202305150700 and the next day it's ABC_202305160700, and so on every day - so I can hardcode the input path as ABC_TODAYSDATE0700.  However, the team that sends this file sometimes randomly changes the name to ABC_TODAYSDATE0701, and they don't know why this is happening.  Is there a way I can read this file and omit the last 4 digits of the path.. so if the name randomly changes it doesn't affect my input path address name?  Thank you

3 REPLIES 3
PaigeMiller
Diamond | Level 26

You can scan your operating system for the folder/path name. The exact instructions depend on what operating system you are using.

--
Paige Miller
Tom
Super User Tom
Super User

Looks like the last 4 digits represent the hour and minute.  So one some days there is a delay and the job doesn't run until 7:01 am instead at 7 am.

 

It is probably best if you get the list of filenames and then decide which one you want to read.

 

If you have XCMD option enabled you can just use a PIPE to run the operating system command to list the file names and read the output.

data files ;
  infile 'ls -d /path_where_files_live/ABC_*'  pipe truncover;
  input filename $256. ;
run;

Otherwise use some tool like https://github.com/sasutils/macros/blob/master/dirtree.sas that use SAS functions to read the filenames.

 

You could then find the filename with a DATE part of its name that matches today.

data todays_file;
  set files;
  date = input(substr(scan(filename,-1,'/'),5,??yymmdd8.);
  time = input(substr(scan(filename,-1,'/'),13,??hhmmss4.);
  format date yymmdd10. time tod5. ;
  if date=today();
run;

Now use that filename in your code. Either directly or by using CALL SYMPUTX() to create a macro variable you could reference in the code.

 

ballardw
Super User

@podarum wrote:

I have a daily symput address path that I get from another team, the only changes to this path is the current day.  For example the name of this path is ABC_20230550700 and the next day it's ABC_202305160700, and so on every day - so I can hardcode the input path as ABC_TODAYSDATE0700.  However, the team that sends this file sometimes randomly changes the name to ABC_TODAYSDATE0701, and they don't know why this is happening.  Is there a way I can read this file and omit the last 4 digits of the path.. so if the name randomly changes it doesn't affect my input path address name?  Thank you


Really, they can't read the code that assigns the value? Any bet they are pulling something from a clock and rounding? Sometimes the process takes just a tiny bit longer and rounds up to one more minute? I think the first time I saw values behave like this involved tape reading/writing in 1987 or so...

 

Maybe someone needs and introduction to a truncation function instead of a rounding function? If you don't have multiple files generated in a day then why do they bother appending something that looks very likely to be a TIME value? The system should be keeping track of such when needed.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 3 replies
  • 384 views
  • 0 likes
  • 4 in conversation