While I review other's program,see code like this '%str(ERR)OR','%str(WARN)ING',why programming like this other than "%str(ERROR)",%strWARNING
my fault,it's '%str(warning)'
Because they are using lazy log scanning tools that cannot tell the difference between the text ERROR in the code and an actual ERROR message generate by that code (or by SAS itself). By adding the extra macrro quoting (which is NOT needed) then the code no longer has the text ERROR as there is a ) in the middle of it. Using %STR(ERROR) would defeat that purpose.
Personally I use this grep string to search for ERROR messages and I do not get false positives from code lines echoed in the log.
grep '^ERROR.*:' myfile.log
This is a convention we use in the SASjs Core library quite extensively.
This library was built to support lazy programmers, and sometimes the fastest way to search for an error in a log (especially within applications that do not support regex by default, such as a browser) is simply to CTRL+F and type "ERROR".
By breaking up the word ERROR into %str(ERR)OR, the number of false positives are drastically reduced. That is the only reason.
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.
Ready to level-up your skills? Choose your own adventure.