<?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: _Error_ in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Error/m-p/62914#M13676</link>
    <description>_error_ is retained because SAS programmers programmed it that way.</description>
    <pubDate>Sun, 16 Jan 2011 17:53:19 GMT</pubDate>
    <dc:creator>bheinsius</dc:creator>
    <dc:date>2011-01-16T17:53:19Z</dc:date>
    <item>
      <title>_Error_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error/m-p/62913#M13675</link>
      <description>Greetings:&lt;BR /&gt;
&lt;BR /&gt;
Another beginner question. Why does SAS retain _Error_  (the automatic variable) value at the end of a data step processing? &lt;BR /&gt;
&lt;BR /&gt;
Here is the wording on my big SAS book (SAS Certification Prep Guide).  '...the value of _N_ is set to 2 and control returns to the top of the Data step. Finally, the variable values in PDV are re-set to missing. Notice that the automatic variable _Error_ retains its value.'   I thought it has to reset _Error_ to 0 for the next cycle of execution?&lt;BR /&gt;
&lt;BR /&gt;
Thank you for your time!</description>
      <pubDate>Sat, 15 Jan 2011 05:33:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error/m-p/62913#M13675</guid>
      <dc:creator>mnew</dc:creator>
      <dc:date>2011-01-15T05:33:46Z</dc:date>
    </item>
    <item>
      <title>Re: _Error_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error/m-p/62914#M13676</link>
      <description>_error_ is retained because SAS programmers programmed it that way.</description>
      <pubDate>Sun, 16 Jan 2011 17:53:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error/m-p/62914#M13676</guid>
      <dc:creator>bheinsius</dc:creator>
      <dc:date>2011-01-16T17:53:19Z</dc:date>
    </item>
    <item>
      <title>Re: _Error_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error/m-p/62915#M13677</link>
      <description>The _ERROR_ variable allows us to check for errors across the execution of the step.  Since we have the ability to query its value whenever we want (and to reset its value), we can detect errors at either the row level or at the level of execution across the entire step.</description>
      <pubDate>Sun, 16 Jan 2011 19:15:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error/m-p/62915#M13677</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2011-01-16T19:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: _Error_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error/m-p/62916#M13678</link>
      <description>Hi.&lt;BR /&gt;
I think that _Error_  retains its value is because of _Error_ is system variable not as the temporary variable which will reset missing at next data step .&lt;BR /&gt;
_Error_ is just like _n_ which is also retain its value at next data step.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Mon, 17 Jan 2011 05:14:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error/m-p/62916#M13678</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-01-17T05:14:04Z</dc:date>
    </item>
    <item>
      <title>Re: _Error_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error/m-p/62917#M13679</link>
      <description>I have to disagree with Ksharp, the behavior with _N_ is not consistent with _ERROR_ .&lt;BR /&gt;
&lt;BR /&gt;
And also to seek clarification from the OP, as I don't see where the value of _ERROR_ is actually "retained" across DATA step iterations, as its value is reset to zero.&lt;BR /&gt;
&lt;BR /&gt;
When a DATA step returns to the top, the _N_ is reset to the next data-value and does not "retain" the prior iteration value, not even before a SET is executed.&lt;BR /&gt;
&lt;BR /&gt;
And, in the case of _ERROR_, SAS also does not retain the prior DATA step iteration value.&lt;BR /&gt;
&lt;BR /&gt;
A code-snippet is listed below this post to demonstrate - for those who want to execute it on their own SAS system.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
data x;                             &lt;BR /&gt;
do a=1 to 4;                        &lt;BR /&gt;
  output;                           &lt;BR /&gt;
end;                                &lt;BR /&gt;
stop;                               &lt;BR /&gt;
run;                                &lt;BR /&gt;
DATA _null_;                        &lt;BR /&gt;
PUTLOG '&amp;gt;BEFORE-SET&amp;gt;' / _ALL_;      &lt;BR /&gt;
set x;                              &lt;BR /&gt;
if a = 2 then x = input('a',best.); &lt;BR /&gt;
PUTLOG '&amp;gt;AFTER-SET&amp;gt;' / _ALL_;       &lt;BR /&gt;
RUN;</description>
      <pubDate>Mon, 17 Jan 2011 18:11:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error/m-p/62917#M13679</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-01-17T18:11:52Z</dc:date>
    </item>
    <item>
      <title>Re: _Error_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error/m-p/62918#M13680</link>
      <description>As Scott points out the temporary variable _ERROR_'s value does persist beyond the DATA step boundary.</description>
      <pubDate>Tue, 18 Jan 2011 03:01:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error/m-p/62918#M13680</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2011-01-18T03:01:19Z</dc:date>
    </item>
    <item>
      <title>Re: _Error_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error/m-p/62919#M13681</link>
      <description>The value of _ERROR_ is only maintained until it is reset by the user, influenced/assigned based on another INPUT function or use of an INPUT statement with a suitable INFORMAT.  &lt;BR /&gt;
&lt;BR /&gt;
However, when you return to the top of a DATA step execution, the value is reset to _ERROR_=0 -- it's prior step-execution value is not maintained.&lt;BR /&gt;
&lt;BR /&gt;
This behavior is inherent to the SAS system architecture.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.

Message was edited by: sbb</description>
      <pubDate>Tue, 18 Jan 2011 03:21:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error/m-p/62919#M13681</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-01-18T03:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: _Error_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error/m-p/62920#M13682</link>
      <description>I should have mentioned that the automatic macro variable &amp;amp;SYSERR does persist across step boundaries, and can be used to evaluate the success of a step at the step level.</description>
      <pubDate>Tue, 18 Jan 2011 05:21:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error/m-p/62920#M13682</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2011-01-18T05:21:24Z</dc:date>
    </item>
    <item>
      <title>Re: _Error_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error/m-p/62921#M13683</link>
      <description>Thanks everyone! Scott's testing codes are very educational. I now know how to check the values in PDV (yes, a real step for a beginner). All the abstract talk about data step iterations now makes a little more sense to me, as I could see the action in snapshots. Also thanks for the &amp;amp;SYSERR tip! I didn't know it exists at all.</description>
      <pubDate>Tue, 18 Jan 2011 06:11:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error/m-p/62921#M13683</guid>
      <dc:creator>mnew</dc:creator>
      <dc:date>2011-01-18T06:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: _Error_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error/m-p/62922#M13684</link>
      <description>To ArtC:  From the SAS DOC (link below), there is indication that the SYSERR macro variable *IS* reset at the step-boundary.&lt;BR /&gt;
&lt;BR /&gt;
SAS 9.2 Macro Language:  Automatic Macro Variables, SYSERR Automatic Macro Variable&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a000208995.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a000208995.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Tue, 18 Jan 2011 12:32:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error/m-p/62922#M13684</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-01-18T12:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: _Error_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error/m-p/62923#M13685</link>
      <description>Thank you Scott for reminding me that I need to remember to be more precise in what I write. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; The &amp;amp;SYSERR is reset at the start of a step.  This means that it can be used/checked after a step (after RUN or QUIT), until it is reset for the next step.  Which takes place once the step threshold has been crossed (PROC or DATA statement).&lt;BR /&gt;
[pre]proc sort data=abc;&lt;BR /&gt;
by x;&lt;BR /&gt;
run;&lt;BR /&gt;
%put &amp;amp;syserr;&lt;BR /&gt;
data  new;%put &amp;amp;syserr;&lt;BR /&gt;
set sashelp.class;&lt;BR /&gt;
run;[/pre]</description>
      <pubDate>Wed, 19 Jan 2011 00:22:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error/m-p/62923#M13685</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2011-01-19T00:22:58Z</dc:date>
    </item>
    <item>
      <title>Re: _Error_</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error/m-p/487834#M127134</link>
      <description>&lt;P&gt;This may be useful to someone. I was looking to control SAS processing, based on the value of _ERROR_. If the value of error can be converted into a macro variable, then this becomes possible.&amp;nbsp; The code is as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc delete data = have;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;set sashelp.class;&lt;BR /&gt;call symputx(' error ', _error_);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%put &amp;amp;error;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc delete data = have;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;set sashelp.class;&lt;BR /&gt;v = 10 + 'GGGGGG';&lt;BR /&gt;call symputx(' error ', _error_);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%put &amp;amp;error;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc delete data = have;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;set sashelp.class;&lt;BR /&gt;call symputx(' error ', _error_);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%put &amp;amp;error;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Aug 2018 16:30:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error/m-p/487834#M127134</guid>
      <dc:creator>tmoorman</dc:creator>
      <dc:date>2018-08-17T16:30:22Z</dc:date>
    </item>
  </channel>
</rss>

