Oct 6, 2010

PUTLOG statement

The PUTLOG statement writes a message that you specify to the SAS log.
The PUTLOG statement is helpful when you use macro-generated code because you can send output to the SAS log without affecting the current file destination.
The PUTLOG statement is similar to the ERROR statement except that PUTLOG does not set _ERROR_ to 1.
The PUT statement writes to the LOG or to an External File with a FILE statement, but the PUTLOG statement always writes to the LOG.
Try this example…
data ExamScores;
   input Name $ 1-16 Score1 Score2 Score3;
Sullivan, James   86 92 88
Martinez, Maria   95 91 92
Guzik, Eugene     99 98 .
Schultz, John     90 87 93
van Dyke, Sylvia  98 . 91
Tan, Carol        93 85 85
data _null_;
set ExamScores end=last;
file "C:\oust.csv" lrecl=256 dlm=",";
put (_all_) (:); /* The colon here is dummy and has no effect */
if last then putlog "NOTE: Writing to the File is completed";
Here in the above example, When the FILE statement is in effect any PUT statement would write to the the external File….Then how would you write some informational messages to the LOG ?.
The PUTLOG statement can be used here to write to the LOG…You can precede your message text with WARNING, MESSAGE, or NOTE to better identify the output in the log…

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.