BookmarkSubscribeRSS Feed
ThomasH
Calcite | Level 5
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.
7 REPLIES 7
Patrick
Opal | Level 21
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
DanielSantos
Barite | Level 11
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
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.
ThomasH
Calcite | Level 5
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
martha_sas
SAS Employee
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.
DanielSantos
Barite | Level 11
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
ThomasH
Calcite | Level 5
Nope, unfortunately I'm running 9.1, but I'll keep this in mind for somewhen else. So thanks for the hint! :) Message was edited by: ThomasH

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 1630 views
  • 0 likes
  • 5 in conversation