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