BookmarkSubscribeRSS Feed
wzl9527
Calcite | Level 5

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

5 REPLIES 5
wzl9527
Calcite | Level 5

my fault,it's '%str(warning)'

Tom
Super User Tom
Super User

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

 

wzl9527
Calcite | Level 5
thank you!
AllanBowe
Barite | Level 11

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.

/Allan
MacroCore library for app developers
Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs
wzl9527
Calcite | Level 5
Thanks!

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1332 views
  • 2 likes
  • 3 in conversation