BookmarkSubscribeRSS Feed
EMC9
Obsidian | Level 7

Good day

 

I have a code that needs to run on the 15th of each month - i want to automate and I have only solved for the weekday

 

I am looking for a code like below or more viable way to achieve this.

 

******SAMPLE*********
DATA _NULL_;
CALL SYMPUT("WD",PUT(WEEKDAY(TODAY()),BEST2.));
RUN;

%IF &WD. = 6 %THEN
%DO;

 

Thanks

3 REPLIES 3
andreas_lds
Jade | Level 19

Running code regularly is the job of a scheduler, you should not do this in a sas program.

 

data _null_;
  if day(today()) = 15 then do;
    rc = dosubl('insert_your_macro_here');
  end;
run;
EMC9
Obsidian | Level 7

Thanks for the reply :

 

I am using LSF scheduler & we have 1 monthly job with multiple flows , the monthly job runs daily but would need the code to only execute if the conditions are met , in my example the monthly job runs daily but only executes once it is the 15th , hope this gives some clarity to a new solution.

 

so the below does work but not in this instance.

 

 

thanks  

andreas_lds
Jade | Level 19

@EMC9 wrote:

Thanks for the reply :

 

[...]

so the below does work but not in this instance.

 



"does not work" can mean anything. Instead of using dosubl to execute a single macro containing the code that has to be executed on the 15th day of each month, you could change that to the logic you had. The function DAY returns the day-part of a date.

 

data _null_;
  call symputx("day", day(today()));
run;

%if &day. = 15 %then
%do;
...
%end;

 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 3 replies
  • 1358 views
  • 2 likes
  • 2 in conversation