BookmarkSubscribeRSS Feed
Babloo
Rhodochrosite | Level 12

I'm trying to capture the return code of DI Job via &syscc. but I observed that it is not resetting for each run. It returns the previous return code for every run instead of the providing the actula Job Status. For example, If a Job has ended with Syntax error and the macro variable &syscc. returns 3000 which is correct.

 

If I correct the error and reran the Job then it should return as 0 if the Job has no warnings or error but it still producing the value as 3000 which is return code of previous run.

 

I'm calling the following maro variable in the postcode section of the DI Job. My objective is to return the Job Status code of the Job.

 

%let status_cd=&syscc.;
%PUT *******status of the job is: &status_cd.*****;

Please help me resolve this issue.

11 REPLIES 11
Kurt_Bremser
Super User

Inspect the whole log of the job, including what is happening in all the autoexec parts. A single failed libname sets syscc to a non-zero value, for example.

Kurt_Bremser
Super User

And if this is happening while developing in DI Studio, mind that you stay within the same workspace server session, so you need to reset syscc to zero manually before a test run.

Babloo
Rhodochrosite | Level 12

Ok, Can I tweak my code like this to reset syscc to 0? I confirm there is no error or warning in my log file .

 

%let syscc=0;
%let status_cd=&syscc.;
%PUT *******status of the job is: &status_cd.*****;
Kurt_Bremser
Super User

That's exactly what you need to do.

My "production" programs all have a comment block in which I set the necessary parameters (usually supplied by the scheduler) for a manual run, and the first line of that block is always

%let syscc=0;
Babloo
Rhodochrosite | Level 12

It is not resolving the issue either. DI Job has ended with error as there was some issue in 2nd and 3rd transformation but still &SYSCC returning the code as 0 instead of 3000.

 

 

6379       /*---- Start of Post-Process Code  ----*/
6380       
6381       %let syscc=0;
6382       %let status_cd=&syscc.;
SYMBOLGEN:  Macro variable SYSCC resolves to 0
6383       %PUT *******status of the job is: &status_cd.*****;
SYMBOLGEN:  Macro variable STATUS_CD resolves to 0
*******status of the job is: 0*****
Kurt_Bremser
Super User

It is VERY obvious that, if you set syscc=0 at the end of the job, it will return with a zero, no matter what happened during the job. The reset has to be done at the beginning, so that problems during the job register correctly.

evp000
Quartz | Level 8

Is there a way to know what the codes represent? I will set syscc to 0 so my LSAF process flow continues. But I'm also sending a notification to myself of the status with the code. But which code(s)=error/warning? 

Kurt_Bremser
Super User

Any non-zero code points to a problem and has to keep the scheduler from continuing with other jobs in the chain. To find out what caused the issue, read the log, and then correct your code or any other reason for the failure (like missing/incorrect input data).

evp000
Quartz | Level 8

Thanks for your response. I already know that I don't want to stop the process flow whether there's a warning or error. But I need to investigate so I'm sending myself a message with the syscc value. I just want to know if it encountered an error or a warning. I can't find what the codes represent exactly. This is for SAS LSAF. 

Quentin
Super User

There are papers that suggest syscc values 1-4 are warnings, and >4 are errors.  But the documentation doesn't make that claim.

 

A SYSCC value of 0 at SAS termination indicates success for that operating environment. A nonzero value might indicate an error or warning condition.

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p11nt7mv7k9hl4n1x9zwkralgq1b.htm

 

I still use log scanning to catch error messages, warnings, and bad notes, and send myself those problematic messages.  If you search lexjansen.com, there are tons of papers on log scanning if you want to see that approach.

The Boston Area SAS Users Group is hosting free webinars!

Register now at https://www.basug.org/events.
Kurt_Bremser
Super User

Why do you want to continue a job chain when there is an obvious problem that might cause your data to be irreversebly corrupted?

Anything else than a zero return code MUST not be allowed in automated execution.

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.

Explore 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
  • 11 replies
  • 8089 views
  • 5 likes
  • 4 in conversation