<?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 Is there a way to use SAS error handling to write to/create a table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-use-SAS-error-handling-to-write-to-create-a/m-p/880457#M347883</link>
    <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;I am trying to write some code which when the process errors a control table will be updated with certain values.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;For the moment I have the following but gives a warning creating a work table called error_table and a column called status but no values. I have simplified the table I'm trying to create.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%macro error_check;
%if &amp;amp;syserr &amp;gt; 0 %then %do;
%put This process has errored with the following message: &amp;amp;syserrortext;
%put Writing out status "error" to control table;
data error_table;
status = error;
run;
%end;
%else %do;
%put it is fine;
%end;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Unfortunately I can't seem to get the code working. This is the first time I've used the &amp;amp;syserr macro so I'm wondering if I'm using it wrong should be using some other method. Thanks for any help one can give.&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Tue, 13 Jun 2023 15:54:18 GMT</pubDate>
    <dc:creator>jaxdaxter</dc:creator>
    <dc:date>2023-06-13T15:54:18Z</dc:date>
    <item>
      <title>Is there a way to use SAS error handling to write to/create a table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-use-SAS-error-handling-to-write-to-create-a/m-p/880457#M347883</link>
      <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;I am trying to write some code which when the process errors a control table will be updated with certain values.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;For the moment I have the following but gives a warning creating a work table called error_table and a column called status but no values. I have simplified the table I'm trying to create.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%macro error_check;
%if &amp;amp;syserr &amp;gt; 0 %then %do;
%put This process has errored with the following message: &amp;amp;syserrortext;
%put Writing out status "error" to control table;
data error_table;
status = error;
run;
%end;
%else %do;
%put it is fine;
%end;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Unfortunately I can't seem to get the code working. This is the first time I've used the &amp;amp;syserr macro so I'm wondering if I'm using it wrong should be using some other method. Thanks for any help one can give.&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 13 Jun 2023 15:54:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-use-SAS-error-handling-to-write-to-create-a/m-p/880457#M347883</guid>
      <dc:creator>jaxdaxter</dc:creator>
      <dc:date>2023-06-13T15:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to use SAS error handling to write to/create a table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-use-SAS-error-handling-to-write-to-create-a/m-p/880467#M347888</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think what you may have intended was more like this if you intended to create character variable that said "error".&amp;nbsp; Your current code uses an undefined variable named error, which will default to numeric and missing. Then assign that missing value to the variable Status.&lt;/P&gt;
&lt;PRE&gt;data error_table;
status = "error";
run;&lt;/PRE&gt;
&lt;P&gt;Can you show exactly what you expect the data set Error_status to hold? How do expect to use the data set later?&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2023 16:17:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-use-SAS-error-handling-to-write-to-create-a/m-p/880467#M347888</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-06-13T16:17:33Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to use SAS error handling to write to/create a table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-use-SAS-error-handling-to-write-to-create-a/m-p/880471#M347889</link>
      <description>&lt;P&gt;I've simplified to what I want the table to look like.&lt;/P&gt;&lt;P&gt;Basically a SAS program is running which is processing tables in sequence and I want a table giving a running commentary on the tables status. This program runs at set times. So for example it will run, process 2 tables, stop. Then the next day it will run and process 1 table. For example it may look like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;table_name&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;status&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;table_1&lt;/TD&gt;&lt;TD&gt;success&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;table_2&lt;/TD&gt;&lt;TD&gt;success&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;table_3&lt;/TD&gt;&lt;TD&gt;success&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;table_4&lt;/TD&gt;&lt;TD&gt;error&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the program errors I would like to update this control table to say that the status of the table is errored.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's required basically because that's what the end user wants.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2023 16:31:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-use-SAS-error-handling-to-write-to-create-a/m-p/880471#M347889</guid>
      <dc:creator>jaxdaxter</dc:creator>
      <dc:date>2023-06-13T16:31:39Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to use SAS error handling to write to/create a table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-use-SAS-error-handling-to-write-to-create-a/m-p/880542#M347910</link>
      <description>&lt;P&gt;What is your actual use case here? Checking the return code of every DATA step isn't going to tell you if it was successful or not, it will only tell you if there were no errors or warnings. A DATA step can run without errors but not have the correct data for example. Only examining the SAS log will offer more evidence of success or not.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2023 20:30:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-to-use-SAS-error-handling-to-write-to-create-a/m-p/880542#M347910</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-06-13T20:30:06Z</dc:date>
    </item>
  </channel>
</rss>

