LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (January 2008, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 17 Jan 2008 08:57:17 -0800
Reply-To:     Jack Hamilton <jfh@STANFORDALUMNI.ORG>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jack Hamilton <jfh@STANFORDALUMNI.ORG>
Subject:      Re: Trivia - Logging custom NOTE, WARNING, and ERROR.
Comments: To: "Richard A. DeVenezia" <rdevenezia@WILDBLUE.NET>
In-Reply-To:  <l6Kjj.66$6J3.18451@news.sisna.com>
Content-Type: text/plain; charset="ISO-8859-1"

Two other options for generating log messages don't seem to be as well known.

PUTLOG is almost the equivalent of FILE LOG followed by a PUT statement. If you already have an another output file open, PUTLOG lets you keep it open while writing to the log. The statement putlog 'WARNING: this is a warning'; writes a warning message to the log.

ERROR is almost the equivalent of FILE LOG followed by PUT and _error_ = 1 . If you want the word "error" to appear in the log, you must specify it explicitly: error 'ERROR: this is an error'; . If you don't explicitly start the text with ERROR:, it won't get error highlighting in the log.

I say "almost the equivalent" because my recollection is that PUTLOG and ERROR don't have all the power of the regular PUT statement. I don't have any documentation for this, and neither need nor curiosity has compelled me to investigate.

On Thu, 17 Jan 2008 10:04:23 -0500, "Richard A. DeVenezia" <rdevenezia@WILDBLUE.NET> said: > Many people know that they can log their own NOTEs and have them color > highlighted in the SAS DMS, or EG log viewer. > > A log line, emitted by macro, that starts with the tag NOTE:, WARNING: or > ERROR: may have the tag replaced with spaces when the text that follows > the > tag starts with dashes, or some spaces followed by some dashes. > > options nosource; > data _null_; > put "NOTE: This is my message. It has special coloring in the log > window."; > put "WARNING: This is my message. It has special coloring in the > log > window."; > put "ERROR: This is my message. It has special coloring in the > log > window."; > run; > > * It should be obvious that the log window renderer is examing the log > contents and applying colors according to its internal rules; > > * The same technique can be used in MACRO via the %put statement; > > %put NOTE: This is my message. It has special coloring in the log > window.; > %put WARNING: This is my message. It has special coloring in the log > window.; > %put ERROR: This is my message. It has special coloring in the log > window.; > > * In some cases I like to sandwich the custom note between dashed lines > to > make it more obvious; > > data _null_; > put "NOTE: -------------------------"; > put "NOTE: This is my message. It has special coloring in the log > window."; > put "NOTE: -------------------------"; > run; > > * The TRIVIA. When this technique is applied from within the macro > environment, the SAS executor will replace the NOTE: text in the lines > with > the dashes with five spaces. > > %put NOTE: -------------------------; > %put NOTE: This is my message. It has special coloring in the log > window.; > %put NOTE: -------------------------; > > The same replacement occurs when doing WARNING or ERROR. > > In some other cases, the sandwich material is replaced with spaces! > Experimentation shows this happens when the 'bread' is an ampersand, or a > macro var containing only macro quoted double quotes or macro quoted > single > quotes. > > %macro logging_check(tag=NOTE, lower=32, upper=127); > %do code = &lower. %to &upper.; > %let char = %qsysfunc(byte(&code.)); > %let string = %sysfunc(repeat(&char.,24)); > > %put %str( ); > %put code=&code.; > %put &tag.: %superq(string); > %put &tag.: This is a message for %superq(char); > %put &tag.: %superq(string); > %end; > %mend; > > %logging_check(lower=32, upper=64); > > * some final experiments; > > %put ------------; > > %put NOTE:-; > %put NOTE:-a; > %put NOTE:-ab; > %put NOTE:-abc; > > %put NOTE: -; > %put NOTE: -a; > %put NOTE: -ab; > %put NOTE: -abc; > > %put NOTE: -; > %put NOTE: -a; > %put NOTE: -ab; > %put NOTE: -abc; > > %put ------------; > > %put NOTE:--; > %put NOTE:--a; > %put NOTE:--ab; > %put NOTE:--abc; > > %put NOTE: --; > %put NOTE: --a; > %put NOTE: --ab; > %put NOTE: --abc; > > %put NOTE: --; > %put NOTE: --a; > %put NOTE: --ab; > %put NOTE: --abc; > > %put ------------; > > -- > Richard A. DeVenezia > http://www.devenezia.com/

-- Jack Hamilton Sacramento, California jfh@alumni.stanford.org


Back to: Top of message | Previous page | Main SAS-L page