<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Can SAS Write the text of an Error Message to a field? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Can-SAS-Write-the-text-of-an-Error-Message-to-a-field/m-p/792371#M253857</link>
    <description>&lt;P&gt;Look at the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/n0f6lmit5jr1xen1dl1owpkufvfj.htm" target="_blank" rel="noopener"&gt;SYSERRORTEXT&lt;/A&gt; automatic macro variable.&lt;/P&gt;</description>
    <pubDate>Wed, 26 Jan 2022 07:44:33 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-01-26T07:44:33Z</dc:date>
    <item>
      <title>Can SAS Write the text of an Error Message to a field?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-SAS-Write-the-text-of-an-Error-Message-to-a-field/m-p/792369#M253856</link>
      <description>&lt;P&gt;A program I run frequently generates two ERROR messages.&amp;nbsp; Is there a way to have the message written to a variable and saved in a database?&amp;nbsp; Note that I am looking for the actual text of the ERROR message to be written to a variable.&amp;nbsp; For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Incomplete JSON in input&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd like to save the string "Incomplete JSON in input" as the value in a field, call it errorlog.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jan 2022 07:32:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-SAS-Write-the-text-of-an-Error-Message-to-a-field/m-p/792369#M253856</guid>
      <dc:creator>texasmfp</dc:creator>
      <dc:date>2022-01-26T07:32:28Z</dc:date>
    </item>
    <item>
      <title>Re: Can SAS Write the text of an Error Message to a field?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-SAS-Write-the-text-of-an-Error-Message-to-a-field/m-p/792371#M253857</link>
      <description>&lt;P&gt;Look at the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/n0f6lmit5jr1xen1dl1owpkufvfj.htm" target="_blank" rel="noopener"&gt;SYSERRORTEXT&lt;/A&gt; automatic macro variable.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jan 2022 07:44:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-SAS-Write-the-text-of-an-Error-Message-to-a-field/m-p/792371#M253857</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-01-26T07:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: Can SAS Write the text of an Error Message to a field?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-SAS-Write-the-text-of-an-Error-Message-to-a-field/m-p/792375#M253861</link>
      <description>&lt;P&gt;Thanks Kurt.&amp;nbsp; While that is a neat tidbit, it seems to only put the 2nd line of the 2-line error message.&amp;nbsp; For example, when I get the following error&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Incomplete JSON in input&lt;/P&gt;
&lt;P&gt;ERROR: Error in the LIBNAME statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;syserrortext; only prints the 2nd of the two lines in the log&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SYMBOLGEN: Macro variable SYSERRORTEXT resolves to Error in the LIBNAME statement.&lt;BR /&gt;Error in the LIBNAME statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately, I am trying to distinguish between two different errors, but each has the same 2nd message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Incomplete JSON in input&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF00FF"&gt;ERROR: Error in the LIBNAME statement.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;versus&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Physical file does not exist, e:\SAS Temporary Files\_TD10912_DESKTOP-575EP3T_\#LN01301.&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF00FF"&gt;ERROR: Error in the LIBNAME statement.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jan 2022 08:02:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-SAS-Write-the-text-of-an-Error-Message-to-a-field/m-p/792375#M253861</guid>
      <dc:creator>texasmfp</dc:creator>
      <dc:date>2022-01-26T08:02:20Z</dc:date>
    </item>
    <item>
      <title>Re: Can SAS Write the text of an Error Message to a field?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-SAS-Write-the-text-of-an-Error-Message-to-a-field/m-p/792381#M253864</link>
      <description>&lt;P&gt;That will be a problem with steps causing more than one message, as the macro variable always displays the last message only.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can only propose two workarounds:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;check the automatic macro variables SYSCC and SYSERR to see which codes are set when your "target problem" arises. From these you can then possibly deduct the ERROR text.&lt;/LI&gt;
&lt;LI&gt;if this has to be done for batch programs, check the log file after the program ends for the text and, if encountered, run a quick SAS program that adds the program name and message to a dataset. Basically, do a simple log file parsing.&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Wed, 26 Jan 2022 08:26:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-SAS-Write-the-text-of-an-Error-Message-to-a-field/m-p/792381#M253864</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-01-26T08:26:54Z</dc:date>
    </item>
    <item>
      <title>Re: Can SAS Write the text of an Error Message to a field?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-SAS-Write-the-text-of-an-Error-Message-to-a-field/m-p/792389#M253869</link>
      <description>&lt;P&gt;Kurt:&amp;nbsp; neither of those will work, but there is yet another system variable that appears to work:&amp;nbsp; &amp;amp;syslibrc appears to generate different values for the two errors.&amp;nbsp; Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jan 2022 08:49:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-SAS-Write-the-text-of-an-Error-Message-to-a-field/m-p/792389#M253869</guid>
      <dc:creator>texasmfp</dc:creator>
      <dc:date>2022-01-26T08:49:54Z</dc:date>
    </item>
  </channel>
</rss>

