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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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