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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.