SAS Programming

DATA Step, Macro, Functions and more
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
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

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!

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

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

Browse our catalog!

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