SAS Warehouse
Paper 096-29
Write Log (%WL) a Production Logging Utility for Data Transactional
Logs
Brett C. Peppe, T-Mobile (USA), Bellevue, WA
ABSTRACT
Often SAS Data Warehousing application programmers encounter situations where a formatted log entry must be
written for later review or a permanent record. For example, the record of a production job run. Successful log
messages are standardized, easy to maintain and efficient to use. The %WL() macro automates many of these log
writing tasks in a simple form:
%WL( P0, P1, P2, P3, P4, off=nn );
INTRODUCTION
The %WL macro automates the process of creating log records and in so doing, frees the programmer to concentrate on the
particulars of the D/W task at hand. It follows the KISS principle (Keep it Simple, Simon), has a tiny code footprint and
automates many common log tasks. The example presented is tailored to writing log records to flat file storage, but the
technique can be adapted to any output medium. Such storage is ideal for transactional logs because it is inexpensive,
flexible and easy to search via GREP or other utility. A simple end-to-end example of this powerful technique is presented.
THE PROBLEM
Anyone who has worked on enterprise grade Data Warehousing (D/W) projects knows that such projects are eventually
judged on three data issue perceptions:
o Is the organization of the data suitable?
o Is the classification of the data adequate?
o Is the data clean enough?
Achieving the first two of these objectives is not a simple task, but can be done if the architects and implementers of the D/W
understand the sources of the data and the requirements of the users. However cleaning the data is also critical to the long-
term success of a D/W, but usually is allocated insufficient resources. Human nature being what it is, everyone one wants to
be the D/W architect (designer), no one wants to be the D/W janitor (cleaner). Clean data is auditable and reconcilable
against its sources.
D/W projects are notorious for requiring complex and sophisticated transactional data loaders. It common to implement
some of the required data validation rules used by these data loaders as referential integrity checks, data maps or error tables.
But this approach is not always suitable because of cost, performance and the lack of a crystal ball to see future requirements.
Despite these limitations, the D/W still needs to efficiently track exception conditions encountered, processing statistics,
status, etc. What to do?
THE SOLUTION
Creating D/W tables to store all the required message conditions on a large project can be very costly. A better approach is
to use cheap flat storage in the form of a run or audit log. The structure of this log can range from the very simple to the
complex. This paper describes a conceptual macro framework that is simple to build, easy to maintain, robust and very
flexible. The important concept to grasp is that %WL will work with any set of strings, be it stored in a dataset, created in a
data step or a format VALUE clause. %WL allows programmers to concentrate on the programming task, rather then
worrying about log formatting.
A SAS macro is nothing more then a better way to generate text using a template. The %WL macro, or its derivatives
illustrate a powerful technique to create logs that are:
o Standardized
o Easy to Maintain
o Efficient to Use
Everyone has a horror story about reading very large unstructured logs created via SAS PUT statements in data steps. %WL
is the end product of an evolution that started many years ago when I found myself mired in one such exercise. A log is

nothing more then a sequential list of messages. Standardized messages are always much easier to understand, both for the
longer join recovery servers to production domains....Windows 2000 Backup Utility (NTBackup.exe) In ...plus one week of transactional log files, might ...
longer join recovery servers to production domains....Windows 2000 Backup Utility (NTBackup.exe) In ...plus one week of transactional log files, might ...
热门文档