BookmarkSubscribeRSS Feed
KJazem
Obsidian | Level 7

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.

1 REPLY 1
Kurt_Bremser
Super User

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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 746 views
  • 0 likes
  • 2 in conversation