BookmarkSubscribeRSS Feed
Hiandbye
Fluorite | Level 6

Hello,

 

So I have a code that contains a macro for a date to always choose the current month. However the code uses a file that gets updated quarterly so that means unless I change the date manually it wont find the latest date file. I think a do loop macro can help? Any ideas?

Thank you!


%macro wrapper;
%if &pdefadjrun=1 %then %do;
%if %sysfunc(exist( file_name_&ReportDateYMD. ))^=1
%then %do;
%put NOTE: file_name_&ReportDateYMD. dataset does not exist;
%end;
%else %if %sysfunc(exist(file_name_&ReportDateYMD. ))=1
%then %do;

 

3 REPLIES 3
PaigeMiller
Diamond | Level 26

I have to say that I am not sure I understand what you are asking.

 

Please describe the problem from scratch. Don't discuss code or macros, just describe what you are trying to do in words.

--
Paige Miller
Hiandbye
Fluorite | Level 6
Thanks! I may have not explained this well. The macro in the code sets the current date but the above code uses a file that updates every quarter. So for example if I want to run this for today I will have to change the &ReportDateYMD to the latest available date file. Is there a way where SAS can find and use the latest available file no matter the current date macro?

Thanks!
PaigeMiller
Diamond | Level 26

@Hiandbye wrote:
Thanks! I may have not explained this well. The macro in the code sets the current date but the above code uses a file that updates every quarter. So for example if I want to run this for today I will have to change the &ReportDateYMD to the latest available date file. Is there a way where SAS can find and use the latest available file no matter the current date macro?

Thanks!

Steps:

  1. Read in all file names in the folder into a SAS data set. (There are plenty of posts here in the SAS Communities which give the code to do this)
  2. Parse the file names to extract the name of the file with the most recent date.

All of this can be done in SAS data steps. No macros needed.

--
Paige Miller

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Early bird rate extended! Save $200 when you sign up by March 31.

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 663 views
  • 2 likes
  • 2 in conversation