Using the Logging Facility Functions in the DATA Step

SAS supplies three logging facility functions that you can use in the DATA step:
creates an appender. FileRefAppender is the only type of appender that can be created by using the SAS language.
logs a message by using a specific logger.
logs a message by using a specific logger.
You use logging facility functions in the same way as you use other functions in SAS: by assigning the function to a variable.
 rc=log4sas_appender("myAppenderName", "FileRefAppender", "fileref=myfiles");
When you create appenders and loggers, remember to create them only once in a DATA step, as in this example:
 if _n_ = 1 then 
   do;
      rc=log4sas_appender("myAppenderName", "FileRefAppender", 
                          "fileref=myfile");
      if rc ne 0 then do;
         msg = sysmsg();
         put msg;
         ABORT;
         end;

      rc=log4sas_logger("myLoggerName", "appender-ref=(myAppenderName) level=info");
      if rc ne 0 then do;
         msg = sysmsg();
         put msg;
         ABORT;
         end;
     end;