A program I run frequently generates two ERROR messages. Is there a way to have the message written to a variable and saved in a database? Note that I am looking for the actual text of the ERROR message to be written to a variable. For example:
ERROR: Incomplete JSON in input
I'd like to save the string "Incomplete JSON in input" as the value in a field, call it errorlog.
Thanks
Kurt: neither of those will work, but there is yet another system variable that appears to work: &syslibrc appears to generate different values for the two errors. Thanks
Thanks Kurt. While that is a neat tidbit, it seems to only put the 2nd line of the 2-line error message. For example, when I get the following error
ERROR: Incomplete JSON in input
ERROR: Error in the LIBNAME statement.
%put &syserrortext; only prints the 2nd of the two lines in the log
SYMBOLGEN: Macro variable SYSERRORTEXT resolves to Error in the LIBNAME statement.
Error in the LIBNAME statement.
Unfortunately, I am trying to distinguish between two different errors, but each has the same 2nd message.
ERROR: Incomplete JSON in input
ERROR: Error in the LIBNAME statement.
versus
ERROR: Physical file does not exist, e:\SAS Temporary Files\_TD10912_DESKTOP-575EP3T_\#LN01301.
ERROR: Error in the LIBNAME statement.
That will be a problem with steps causing more than one message, as the macro variable always displays the last message only.
I can only propose two workarounds:
Kurt: neither of those will work, but there is yet another system variable that appears to work: &syslibrc appears to generate different values for the two errors. Thanks
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.