Chapter Contents |
Previous |
Next |
SAS Companion for the Microsoft Windows Environment |
After opening Event Viewer (found in the Administrative Tools folder or by starting EVENTVWR.EXE), you can view the Application Log by selecting Application from the Log menu. If a SAS task terminates abnormally, information regarding the task is placed into the Application Log. The Source column shows "SAS" as the event source. Messages from SAS/CONNECT display "SAS Job Spawner" as the event source. When you double-click on a SAS event, an Event Detail window similar to the one in Event Detail Dialog Box opens with information about the event. This is the same error message you would see in your SAS Log file or in the SAS Log window.
Sending Messages to the NT Event Log Using a User-Written Function |
SAS System events can be sent to the NT Event Log using a user-written function in either SAS System code or SCL. Input to the function is a specific text string which corresponds to a type of event and the text string that will appear in the Event Viewer. Types of SAS System Events` lists the types of events available for the first parameter.
Type of Event | First Parameter Value |
Error | "ERROR" |
Warning | "WARNING" |
Information | "INFORMATION" |
Success Audit | "SUCCESSAUDIT" |
Failure Audit | "FAILUREAUDIT" |
Although the first parameter values are displayed in upper case,
mixed
case is also allowed. The second parameter of the function is a string that
will appear in the Event Viewer.
The following is an example of some SAS System code in which the existence of a semaphore file is checked before lengthy processing:
%macro pdata(file); %let cmdstr = "dir &file"; options noxwait; data _null_; call system(&cmdstr); run; %put &sysrc = sysrc; %put &file; %if &sysrc=0 %then %do; filename indata "&file"; /* Your data step code for this file. */ DATA a; infile indata length=linelen; length line $ 200; input @1 line $ varying200. linelen; PROC print; run; %end; %else %do; /* Log an NT Event of type Error. */ %let cmdstr = %str("The file &file did not exist so no data step ran."); %put &cmdstr; DATA _null_; x=ntlog("INFORMATION",&cmdstr); run; %end; %mend; %pdata(c:\config.syss)
The following is SCL code to write to the NT Event Log:
/* Build a frame and add a pushbutton. Change the Attribute Name "name" to "object1". In the Source window, add the following code. */ object1: x=ntlog("INFORMATION", "This is an INFORMATION event."); x=ntlog("WARNING", "This is a WARNING event."); x=ntlog("ERROR", "This is an ERROR event."); x=ntlog("SUCCESSAUDIT", "This is a SUCCESSAUDIT event."); x=ntlog("FAILUREAUDIT", "This is a FAILUREAUDIT event."); return;
Sending Messages to the NT Event Log Using LOGEVENT.EXE |
In this example, the existence of a semaphore file is checked before SAS performs some lengthy processing.
%macro pdata(file); %local cmdstr; %let cmdstr = "dir &file"; options noxwait; DATA _null_; call system(&cmdstr); run; %if &sysrc=0 %then %do; filename indata "&file"; /* Your data step code for this file. */ DATA a; infile indata length=linelen; length line $ 200; input @1 line $ varying200. linelen; PROC print; run; %end; %else %do; /* Log an NT Event of type Error. */ %let cmdstr = %bquote(c:\logevent.exe -s E "The file &file did not exist so no data step ran."); DATA _null_; %sysexec &cmdstr; run; %end; %mend; %pdata(c:\config.syss)
When you double-click on the event in the Application Log, the Event Detail dialog box will give you the message displayed in Displaying a User Message in The Event Detail Dialog Box.
Displaying a User Message in The Event Detail Dialog Box
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.