Dear all,
How can I avoid to write the word Error in a way that when I look for errors in my log this word doesn't appear?
data mydata;
set mydata;
label StdErr = "Standard|Error";
run;
I have tried things like "Standard|Err""or", "Standard|Err%str(or)", using a macro variable but nothing of this works.
Thanks!
regards,
juan
Not sure that i understood your question, but when looking for errors in the log searching for "ERROR:" instead of "ERROR" does the trick - the colon is the important thing.
Yes, you got it.
For a period of time I used to look for the word ERROR ticking the case sensitive option in the find window but then I realized that not all errors are uppercase, sometimes you get Error too. Because of this I basically thought SAS might do the same with the colon sometimes use it, sometimes not.
Do you know for sure that all SAS errors are followed by a colon? if so, that might solve my problem.
Thanks for your help andreas.
Here is an example of an error message that does not have a semicolon immediately after the word error.
143 data a; 144 x=1; 145 format x unknown.; -------- 48 ERROR 48-59: The format UNKNOWN was not found or could not be loaded. 146 run;
I have seen a good number of log scanners that will fail to detect such error messages.
a regex like '%ERROR*:' will find that one.
Actually there are ERRORS in the log that don't have a colon immediately after the word error. And sometimes people like to be able to hit CTL-F "error" to search their log. So when writing code (macros typically) that will be used by others, I also try to avoid the work error in my code as much as possible (not everyone uses as an automated log scanner, even if they "should").
I'm stuck on this example however.
For data step PUT statements, I usually do: PUT "ER" "ROR: something bad happened". And the PUT statement doesn't complain at the blank in between.
In macro land I do %PUT %ER%str()ROR: bad parameter value...
I had hoped you could do: Label StdErr="Standard Er" "ror" ; but the label statement complains.
If you are in open code (outside of macro definition) then you can do: Label StdErr="Standard Er%str()ror" ; but if you do that inside of a macro defintion and turn on MPRINT, you will still get the word Error in your log.
I guess if you really wanted to avoid the word error (unless the error condition is generated), you could use the %str() approach, and then in the macro force MPRINT off (and restore it at the end). But that seems like over-kill, and I like MPRINT too much to do that.
Will look forward to seeing responses from others.
--Q.
As you have seen, you'll need to be creative to handle all cases. Some alternate spellings might be acceptable. A couple of ideas:
label StdErr = 'Standard|Err';
label StdErr = 'Standard|E r r o r';
Or you could temporarily reroute the log using PROC PRINTTO.
Or you could temporarily eliminate the source code from the log (OPTIONS NOSOURCE / SOURCE).
But I don't see a perfect solution either.
Good luck.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.