Pages

Monday, 5 October 2009

NOTE: More About NOTE2ERR (a.k.a. Be Of Good Type)

In an earlier post I wrote of the unsupported (and largely undocumented) NOTE2ERR system and data set option. It tells SAS to treat a certain number of "minor" syntax issues as errors instead of notes. Most notably this includes automatic conversion of characters values to numeric and vice-versa.


The post sparked conversation on SAS-L and amongst SAS practitioners at many of RTSL.eu's clients. The topic is clearly one that interests and is of use to many people. Sasplumber thought NOTE2ERR was awesome (and had some nice things to say about the blog too); Lou made a good point about protecting novice SAS programmers from their mistakes rather than punishing them; Ron Fehd suggested documentation could be found if one looked hard enough (fair point); and Jack Hamilton suggested an enhancement that would offer control over which note messages turned to errors (don't hold your breath on that one, Jack!).


The post ended with the comment "why hasn't NOTE2ERR been documented and supported?" Well, we got word from a SAS insider, and this is what they told us:
Interesting question, Andy! I never knew about NOTE2ERR, but I've dug into it and here is my take on it.
Sometimes, you want to hold your DATA step code to a higher standard. You want the DATA step to run quick and clean, and have complete confidence that it did just what you intended it to do. For example, the SAS Enterprise Miner product generates scoring code that often uses DATA step: very efficient, meant for high-use situations. NOTE2ERR allows a tester to ensure that the code being generated is not only error- and warning-free, but NOTE-free.
SAS emits a note because it wants you to be aware of something that you might not be aware of, even if most of the time it's not alarm-worthy. If you don't like those kinds of surprises, NOTE2ERR helps you ferret them out.
As to why it's not documented: it was added for internal use by SAS testers. Very occasionally a customer will call with a question where NOTE2ERR comes in handy, which is how (I suspect) the news of its existence got out.
Your blog post includes good caveats. PROC IMPORT is another one that can use DATA step. SAS proc developers are pretty disciplined about using ERRORs and WARNINGs appropriately. Does the same standard apply for NOTEs? I can't say, but NOTEs probably are not designed with the idea that an end user should be alarmed about them, so NOTE2ERR use as a constant practice might not be a great idea.
There's no specific comment about it becoming a supported feature, so we can assume it won't do so any time soon. But in the meantime, as our little birdy suggests, it's handy to use in testing and debugging.