DATA Step, Macro, Functions and more

Abort only one of several included jobs

Reply
Contributor
Posts: 51

Abort only one of several included jobs

Hi all,

I'm trying to implement a job, which includes 4 others sequentially and insert a conditional statement in job 3, which aborts only this job nr. 3 but then executes the last one.

I understand abort abend/return do abort the whole session with different results. Is there a way to code the above mentioned behaviour?

The jobs are ran in batch mode.

Thanks a lot.
Respected Advisor
Posts: 4,173

Re: Abort only one of several included jobs

Hi Thomas

If you use an %include statement then you have to see this as one job / one chunk of code and not several jobs.
You will therefore have to build your job logic in a way that part of the code is not executed when a certain condition is met. An abort statement will - as you say - abort the whole job.
You could - for example - populate a macro var in your job when the condition is met (using call symput) and then stop this data step using 'stop'. Then have all subsequent steps in a macro where you only execute code if the macro var is not populated.

If this is about having a master job which starts child jobs then you could use rsubmit blocks to spawn jobs (an rsubmit can also be used on the same machine to create several SAS sessions in parallel). Google a bit: There is a white paper explaining on how to do this.

HTH
Patrick
Super Contributor
Posts: 474

Re: Abort only one of several included jobs

If we are talking about SAS coding from end-to-end (multiple child jobs included from a master one), I cannot see anything else that a macro or rsubmit/autosignon solution.

For a macro approach, you could enclose the job nr.3 into one big macro, and then use the %GOTO statement to skip the desired code as necessary.

See: http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a000209058.htm

"Self"-submitting sequentially the desired jobs may also work, just issue the ENDSAS statement to interrupt job nr.3's session without generating an error.

See: http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a000289392.htm

If we are talking about multiple SAS jobs (scripts) submitted externally from SAS (let say JCL, shell script, batch script) then it's a lot more simpler, you just have to control the execution through the JCL/script you are using.

Cheers from Portugal.

Daniel Santos @ www.cgd.pt
Super Contributor
Super Contributor
Posts: 3,174

Re: Abort only one of several included jobs

Posted in reply to DanielSantos
What OS? Is SAS running locally or on a remote server?

And are you running these "jobs" under a comprehensive job-scheduler or manually? Is a scheduler facility available to you or are you expecting to accomplish this processing only within SAS?

How do you currently thread the job-executions - are they submitted manually or is there a "master control job" to sequence the SAS code execution based on prior "job nr." results?

Scott Barry
SBBWorks, Inc.
Contributor
Posts: 51

Re: Abort only one of several included jobs

Thanks a lot for your answers - there are one or two approaches I will look into.

Job scheduling in this case is controlled by one master job.

Regards,
Thomas
SAS Employee
Posts: 19

Re: Abort only one of several included jobs

You can cancel execution of %included file by using
ABORT CANCEL FILE;
or %ABORT CANCEL FILE;

within the %included file at the conditional statement.
This is new in version 9.2. It can be used in a %included file or an autoexec file. There's a warning in the documentation about the effect of ABORT CANCEL FILE on open macros, (it closes them) when executed within a %include file.
Super Contributor
Posts: 474

Re: Abort only one of several included jobs

Posted in reply to martha_sas
This is great!

Didn't knew about this useful feature.

Let's hope Thomas is running 9.2.

Cheers from Portugal.

Daniel Santos @ www.cgd.pt
Contributor
Posts: 51

Re: Abort only one of several included jobs

Nope, unfortunately I'm running 9.1, but I'll keep this in mind for somewhen else. So thanks for the hint! Smiley Happy Message was edited by: ThomasH
Ask a Question
Discussion stats
  • 7 replies
  • 364 views
  • 0 likes
  • 5 in conversation