BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Sandy10
Calcite | Level 5

Hi

 

I ahve to execute a batch scripts(sh script) which calls a SAS job inside a macro, I have to check the return code of the same . How to do ?

%do i=1 to &max;/*Max holds 9 thats 9 jobs*/

 

%let path = /app/jobs;

x "&path/&&jobs&i...&extn";/*extn is sh*/

 %if rc ge 0 /*I have to do this but unabel to get rc value*/

 

Kindly advise

Thanks,
Sandhya S

 

 

1 ACCEPTED SOLUTION
6 REPLIES 6
Kurt_Bremser
Super User

First of all you need to make sure that the shell script returns the RC from SAS. After executing an external command, check the &sysrc automatic macro variable. It contains the return code from the x statement.

For reference, see here: http://documentation.sas.com/?docsetId=mcrolref&docsetTarget=p07ugdul4v0llpn1denhfknmr7sb.htm&docset...

Sandy10
Calcite | Level 5
Hi @Kurt_Bremser

Thanks for your reply. How to check the return code of a SAS job which was executed using below statement ?

%include /app/jobs/J_ABC.sas";

Thanks and Regards
Sandhya S
LinusH
Tourmaline | Level 20
%include execute the code in the calling session, hence no session rc.
Data never sleeps
Sandy10
Calcite | Level 5
Hi @LinusH

I understand that . But if there anyway i can know whether the job is successful or not?
LinusH
Tourmaline | Level 20

Not sure what you mean by "Job" in this context.

For the "calling" session there will be a rc of course, but the included code is not a job.

If you want to monitor individual steps you can check rc for these. 

If I try to read between the lines, I think you want to monitor each program separately, and the %include's are not a good choice.

Better to set job flows up in a decent scheduler, and have that as a central point of control.

Data never sleeps

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 6 replies
  • 3790 views
  • 1 like
  • 3 in conversation