Using Windows System Tools with SAS under Windows |
Accessing the Application Log Using Windows Vista |
Under Administrative tools, select Event Viewer.
Note: Select Continue if you receive a message stating that Windows needs your permission to continue.
In the tree view, select Windows logs.
Select Application log.
Accessing the Application Log Using Windows 7 |
To open the Application Log:
Open the Control Panel.
Select System and security.
Under Administrative tools, select Event Viewer.
Note: Select Continue if you receive a message stating that Windows needs your permission to continue.
In the tree view, select Windows logs.
Select Application log.
Accessing the Application Log Using Windows Server 2003 |
Using Windows Server 2003, you access the Application Log from the Event Viewer tree view:
An alternate method of starting the Event Viewer is to type eventvwr in the Run dialog box and click OK.
Accessing the Application Log Using Windows XP |
Using Windows XP, you access the Application Log from the Event Viewer tree view:
An alternate method of starting the Event Viewer is to type eventvwr in the Run dialog box and click OK.
Viewing a SAS Event |
If a SAS task ends abnormally, information about the task is placed in the Application Log. The Source column shows "SAS" as the event source. Messages from SAS/CONNECT display "SAS Job Spawner" as the event source. Double-clicking a SAS event opens the Event Properties window that contains information about the event.
Sending Messages to the Application Log Using a User-Written Function |
SAS events can be sent to the Application Log by using a user-written function in either SAS code or SAS Component Language (SCL). Input to the function is a specific text string. This text string corresponds to the type of event and to the text string that will appear in the Event Viewer:
yourfunction("type_of_event", "text_string");
The following table lists the types of events that are 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 that are displayed in the table are shown in uppercase, mixed case is also allowed. The second parameter of the function is a string that will appear in the Windows Event Viewer.
In the following example, the existence of a semaphore file is checked before SAS performs 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 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 Application 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 Application Log Using LOGEVENT.EXE |
Using the Windows LOGEVENT.EXE utility that is provided by the Windows Resource Kit, you can send your own information messages to the Application Log from within SAS code.
In the following 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 Event of type Error. */ %let cmdstr = %bquote(c:\support\sasset2\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 the event in the Application Log, the Event Properties window will display the message in the Description box.
Displaying a User Message in The Event Detail Dialog Box
For information about LOGEVENT.EXE, see the documentation for the Windows Resource Kit.
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.