Another beginner question. Why does SAS retain _Error_ (the automatic variable) value at the end of a data step processing?
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?
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.
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 .
_Error_ is just like _n_ which is also retain its value at next data step.
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 &SYSERR tip! I didn't know it exists at all.
Thank you Scott for reminding me that I need to remember to be more precise in what I write. :-) The &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).
[pre]proc sort data=abc;
data new;%put &syserr;