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.
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.
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.
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.*****;
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;
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*****
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.
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!
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.