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 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 6 replies
  • 4329 views
  • 1 like
  • 3 in conversation