BookmarkSubscribeRSS Feed
Babloo
Rhodochrosite | Level 12

May I know what are the different types of &job_rc available for a DI Jobs? I know that 0 denotes successful run and I would like to know about other return codes which I'm unable to find it in the document.

5 REPLIES 5
Patrick
Opal | Level 21

Assuming this question is related to here https://communities.sas.com/t5/SAS-Data-Management/SAS-DI-Job-tracking-details/m-p/586679#M17938:

Why don't you just define 3 actions in the transformation - success, warning and error - and then have a look in the generated code which return code ranges are used to select these 3 different conditions.

Babloo
Rhodochrosite | Level 12
I got it but still I would like to know the ranges for &job_rc.

Is this not documented any where?
Patrick
Opal | Level 21

Yes, it is documented and not that hard to find using Google.

 

SYSRC automatic macro variable is populated with a return code that corresponds to any ERRORLEVEL value returned when an operating system command is executed by certain SAS statements. The value that SYSRC returns depends on the underlying operating system.

 

Also: Be very clear not to confuse the macro variable &sysrc with the macro %sysrc

http://www.sascommunity.org/wiki/SYSRC_automatic_macro_variable 

 

Using &syscc is eventually easier. 

Babloo
Rhodochrosite | Level 12

I want to capture the Status of DIS Job in one variable. In order to do that I write the code as below in user written code Transformation and connected it to the previous dataset and removed the mapping.  So my DIS Job flow Looks like dataset->table loader->dataset->user written code.

 

STAT_CD="&SYSRC.";

So if my Job has warning in any of the Transformation including the user written Transformation, I want to capture the respective return code to the STAT_CD. However it is always showing as '0' even though there is warning in any of the transfomation.

 

How to correct this issue?

 

Patrick
Opal | Level 21

@Babloo 

That's because &sysrc is the wrong automatic variable for this purpose. You need to use &syscc

BUT.... You are using DIS and DIS generated code has already heaps of in-built error checking and capturing. I believe you would get faster to a better result if you start writing your own code based on what DIS already generates. 

For what you're trying to do why not right-click on a job canvas and define status handling as below. Then go into the code and inspect what gets generated. If that's not already what you need then use at least this code as a starting point for your own implementation. 

Capture.JPG

 

What the DIS generated code will give you are things like:

- It uses the DIS maintained macro variable for the job condition code.

- It handles the case where an upstream error condition sets SAS into syntax check mode

-.......

 

What any "in-job" status reporting can't handle: Cases where the job terminates (i.e. via abort statement) before it reaches the status reporting logic. If you also want to report such cases then you need to execute a separate process outside of the DIS job like for example proposed here by @Kurt_Bremser 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 1450 views
  • 3 likes
  • 2 in conversation