BookmarkSubscribeRSS Feed
JuanVte
Calcite | Level 5

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

6 REPLIES 6
andreas_lds
Jade | Level 19

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.

JuanVte
Calcite | Level 5

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.

Quentin
Super User

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.

BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
data_null__
Jade | Level 19

a regex like '%ERROR*:' will find that one.

Quentin
Super User

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.

BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
Astounding
PROC Star

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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1008 views
  • 6 likes
  • 5 in conversation