Hi.
I have a SAS script that is scheduled to run everyday. I want to terminate the script if a certain condition is satisfied. For example, if it's Sunday, I want to kill the execution of the script at a certain point, and nothing after should execute.
%let _weekday = %sysfunc(weekday(today()));
data _null_;
if &_weekday. = 1 then do;
call execute('endsas;');
end;
stop;
run;
Would this work? Would this affect anything in the next day schedule run or will that run again fine and check the condition again?
Do you recommend another, more graceful way?
Thank you.
Instead of using CALL EXECUTE to push ENDSAS into the execution queue, you can use the ABORT data step statement. It also allows setting the return code of the SAS program.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.