Hi
I used to schedule the SAS codes using windows scheduler. The sas codes are running daily basis from the system.
Now I need to schedule the job only in Monday and Tuesday. And I want to use a logic in macro for running the code in Monday and Tuesadyand disable the other days run .
You do not need a macro for that, a simple datastep with an ABORT statement will suffice:
data _null_;
if weekday(today()) not in(2,3) then
abort return 0;
run;
If you put that in the top of your program, it will only run on Mondays and Tuesdays.
A solution would involved the following language constructs -
%sysfunc macro function
http://documentation.sas.com/?docsetId=mcrolref&docsetVersion=9.4&docsetTarget=p1o13d7wb2zfcnn19s5ss...
%IF-%THEN/%ELSE Statement
%MACRO Statement
today function
http://documentation.sas.com/?docsetId=lefunctionsref&docsetTarget=p0hm9egy8s7mokn1mz0yxng80ax5.htm&...
weekday function
http://documentation.sas.com/?docsetId=lefunctionsref&docsetTarget=p0ahi8tk3trkv5n173sil9hd7c62.htm&...
and lastly
endsas statement
Take a read through this documentation and you should have what you need to put together a nice solution.
You are already using a scheduler:
"windows scheduler"
Within that application, there is the functionality to schedule code to run on specific days. Use that, don't try to re-invent the wheel.
You do not need a macro for that, a simple datastep with an ABORT statement will suffice:
data _null_;
if weekday(today()) not in(2,3) then
abort return 0;
run;
If you put that in the top of your program, it will only run on Mondays and Tuesdays.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.