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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.