DATA Step, Macro, Functions and more

Day macro

Reply
Contributor
Posts: 34

Day macro

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

Super Contributor
Posts: 498

Re: Day macro

Posted in reply to Allistair

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;
Contributor
Posts: 34

Re: Day macro

Posted in reply to andreas_lds

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  

Super Contributor
Posts: 498

Re: Day macro

Posted in reply to Allistair

Allistair 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;

 

 

Ask a Question
Discussion stats
  • 3 replies
  • 107 views
  • 2 likes
  • 2 in conversation