Hi,
I'm trying to capture exit code of a program using the syscc automatic variable.
However, I cannot find the variable in the log of a program that ended with errors.
How can I start capturing syscc in the log?
I am using SAS Studio in SAS Viya 4.
You should show us the code where you attempt to write the Syscc variable to the log.
You should also tell us what the setting of the ERRORCHECK system setting as that may affect the behavior.
This is an example running in foundation or Base SAS that will display the current value after the end of the Print procedure:
proc print data=sashelp.junk; run; %put Value of SYSCC is: &syscc.;
Which shows in the log:
9 proc print data=sashelp.junk; ERROR: File SASHELP.JUNK.DATA does not exist. 10 run; NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE PRINT used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 11 12 %put Value of SYSCC is: &syscc.; Value of SYSCC is: 3000
If you don't provide a description such as my text "Value of SYSCC" in a %put statement then you would only see a 3000 in the log which is pretty hard to tell what it means by itself.
Note that not all statements will set SYSCC even with problems. And depending on how the program is ending you may be ending it before you can write to the log.
You should show us the code where you attempt to write the Syscc variable to the log.
You should also tell us what the setting of the ERRORCHECK system setting as that may affect the behavior.
This is an example running in foundation or Base SAS that will display the current value after the end of the Print procedure:
proc print data=sashelp.junk; run; %put Value of SYSCC is: &syscc.;
Which shows in the log:
9 proc print data=sashelp.junk; ERROR: File SASHELP.JUNK.DATA does not exist. 10 run; NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE PRINT used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 11 12 %put Value of SYSCC is: &syscc.; Value of SYSCC is: 3000
If you don't provide a description such as my text "Value of SYSCC" in a %put statement then you would only see a 3000 in the log which is pretty hard to tell what it means by itself.
Note that not all statements will set SYSCC even with problems. And depending on how the program is ending you may be ending it before you can write to the log.
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
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.
Ready to level-up your skills? Choose your own adventure.