As the first step in the decommissioning of the site has been converted to read-only mode.

Here are some tips for How to share your SAS knowledge with your professional network.

Saving sas logs

From sasCommunity
(Redirected from Saving SAS logs)
Jump to: navigation, search

This article is a minimal description of the files used to save

  • copy of SAS program log using option altlog
  • product usage log using options rtrace and rtraceloc
  • keywords: saving jobs logs

Set Up


These are the folders and files used in this example suite. The root directory-specification -- here: C:\temp\SAS-logs -- may be changed in save-sas-logs.cfg.


SASv9 cfg

Add this line to your SASv9.cfg.

  • file: 'C:\Program Files\SAS\SAS 9.1\SASV9.CFG'
-CONFIG 'C:\temp\SAS-logs\InitStmt\save-sas-logs.cfg'


Save-SAS-logs cfg

This configuration file allocates the directory-specification where both sets of logs are saved.

/* name       : C:\Program Files\SAS\SAS 9.1\save-sas-logs.cfg
   description: assign folders where altlog and rtrace logs are written
   purpose    : centralize allocation of directory-specification of root
folders and files:
C:\temp\SAS-logs\InitStmt\save-sas-logs.cfg this file
** ****************************************/
-Set SASlogs      'C:\temp\SAS-logs'
-Set SASlogAltCfg '!SASlogs\altcfg\altlog.cfg'
-initstmt         "%Inc '!SASlogs\InitStmt\';"
-config           '!SASlogAltCfg'
-rtrace            all
-rtraceloc        '!SASlogs\altcfg\zRtrace-init.log'

Note that rtraceloc must be initialized and that the file-specification is changed by

Save-SAS-logs sas

;/*name    :
description: options to save program       log: altlog
                     to save product usage log: rtraceloc
purpose    : set up site for job monitoring
author     : RJF2 2/18/2008 4:35PM   ***/
%Put NOTE: InitStmt processing beginning, file is %sysget(SASlogs)\;

%* turn on notes when testing via AutoExecTest else silent;
options %sysfunc(ifc(    %sysfunc(getoption(echoauto)) eq ECHOAUTO
                     and %sysfunc(getoption(verbose))  eq VERBOSE

options fullstimer  ;%* full system timer information in log;
options msglevel = I;%* more messages                 in log;

%*   note: altlog is name of *-next-* altlog       keys are in log;
%Let AltCfgText
 = -altlog !SASlogs\altlog\%sysfunc(datetime(),hex16.).log;
%*note: rtraceloc is name of *-this-* rtrace log   keys are in filename;
options rtraceloc
        = "!SASlogs\rtrace\%sysfunc(datetime(),hex16.)-&SysUserId..log";

%*   write testing information to log;
%Put NOTE: InitStmt SASlogs  :%sysget(SASlogs);
%Put NOTE: InitStmt AltCfg   :%sysget(SASlogAltCfg);
%Put NOTE: InitStmt AltLog   :&AltCfgText.;
%Put NOTE: InitStmt RtraceLoc:%sysfunc(getoption(RtraceLoc));

%*   overwrite AltCfg  see: Evar SASlogAltCfg in save-sas-logs.cfg;
%Let                               AltCfgFileRef = ;
%Let AltCfgRc  = %sysfunc(filename(AltCfgFileRef,"!SASlogAltCfg"));
%Put NOTE: AltCfgRc  = &AltCfgRc. 0==filename success;
%Let AltCfgFid = %sysfunc(fopen(&AltCfgFileRef.,o,%length(&AltCfgText.),e));
%Put NOTE: AltCfgFid = &AltCfgFid. 1==fopen    success;
%Let AltCfgRc  = %sysfunc(fput(&AltCfgFid.,&AltCfgText.));
%Put NOTE: AltCfgRc  = &AltCfgRc. 0==fput     success;
%Let AltCfgRc  = %sysfunc(fwrite(&AltCfgFid.));
%Put NOTE: AltCfgRc  = &AltCfgRc. 0==fwrite   success;
%Let AltCfgRc  = %sysfunc(fclose(&AltCfgFid.));
%Put NOTE: AltCfgRc  = &AltCfgRc. 0==fclose   success;
run; options notes;

%*   write header information for ReadLog;
%Let InfoPrefix = PASS-INFO;
%Put &InfoPrefix. FullStimer=%sysfunc(getoption(fullstimer));
%Put &InfoPrefix. Host      =%sysget(computername);
%Put &InfoPrefix. DateTime  =%substr(&SysProcessId.,1,16);
%Put &InfoPrefix. WorkId    =%substr(%scan(%sysfunc(getoption(Work))
                                       ,-1,\) ,4);
%Put &InfoPrefix. UserId    =%upcase(&SysUserId.);
%Put &InfoPrefix. UserNmbr  =%substr(&SysProcessId.,17,5);%*99,999;
%Put &InfoPrefix. SysScpL   =&SysScpl. ;
%Put &InfoPrefix. SysVlong  =&SysVlong.;
%Put &InfoPrefix. MemSize   =%sysfunc(getoption(MemSize ));
%Put &InfoPrefix. SortSize  =%sysfunc(getoption(SortSize));
%Put &InfoPrefix. SumSize   =%sysfunc(getoption(SumSize ));
%Put &InfoPrefix. SysIn     =%sysfunc(getoption(SysIn   )) #;
%Put &InfoPrefix. SysParm   =%sysfunc(getoption(SysParm )) #;
%Put %sysfunc(ifc(    %sysfunc(getoption(echoauto)) eq ECHOAUTO
                  and %sysfunc(getoption(verbose))  eq VERBOSE
%Put NOTE: InitStmt processing completed.;
%symdel AltCfgFid AltCfgRc AltCfgText AltCfgFileRef InfoPrefix;

Example Output

AltLog cfg

This file is overwritten by each SAS job, therefore it is the altlog of the next job. The filename is job-start-datetime() in hex16. This is expected to be a unique filename on any computer. Job identifiers are in the log; compare to rtrace log, where job identifiers are in the filename.

Filename: altlog.cfg named in save-sas-logs.cfg.

-altlog !SASlogs\altlog\41D6A2F9AD9EB852.log

zRtrace-init log

This file is overwritten by every job.

Filename: zRtrace-init.log named in save-sas-logs.cfg.

File referenced: C:\Program Files\SAS\SAS 9.1\sasv9.cfg
File referenced: Z:\admin\SAS-SetInits\sas\sasv9.cfg
File opened: C:\Program Files\SAS\SAS 9.1\sasv9.cfg
File closed: C:\Program Files\SAS\SAS 9.1\sasv9.cfg
File opened: C:\Program Files\SAS\SAS 9.1\nls\en\SASV9.CFG
File closed: C:\Program Files\SAS\SAS 9.1\nls\en\SASV9.CFG
File opened: C:\Program Files\SAS\SAS 9.1\save-sas-logs.cfg
File closed: C:\Program Files\SAS\SAS 9.1\save-sas-logs.cfg
File opened: C:\temp\SAS-logs\altcfg\altlog.cfg
File closed: C:\temp\SAS-logs\altcfg\altlog.cfg
File opened: Z:\admin\SAS-SetInits\sas\sasv9.cfg
File closed: Z:\admin\SAS-SetInits\sas\sasv9.cfg
File referenced:
File referenced: C:\temp\SAS-logs\InitStmt\
File opened: C:\temp\SAS-logs\InitStmt\

Rtrace log

Example filename: 41D6A2AAD564BC6A-rjf2.log named in

This file is overwritten by every job.

The filename contains the job identifiers which are:

  • job-start-datetime() in hex16.
  • hyphen
  • SysUserId

Compare to altlog, where job identifiers are in the file.

File closed: C:\temp\SAS-logs\altcfg\altlog.cfg
File closed: C:\temp\SAS-logs\InitStmt\

For program: save-sas-logs-Test, this is the end of the rtrace .log.

File opened: C:\Temp\SAS-logs\InitStmt\
File closed: C:\Temp\SAS-logs\InitStmt\
File closed: C:\Temp\SAS-logs\InitStmt\save-sas-logs-Test.log
File closed: C:\temp\SAS-logs\altlog\41D6A26A8A87AE14.log

Normal Log

NOTE: InitStmt processing beginning, file is C:\temp\SAS-logs\
PASS-INFO Host      =RJF2-179107
PASS-INFO WorkId    =180
PASS-INFO UserNmbr  =40200
PASS-INFO SysVlong  =9.01.01M3P020206
PASS-INFO MemSize   =0
PASS-INFO SortSize  =67108864
PASS-INFO SumSize   =0
PASS-INFO SysIn     =C:\Temp\SAS-logs\InitStmt\ #
PASS-INFO SysParm   = #
NOTE: InitStmt processing completed.

AutoExecTest Log


-- created by User:Rjf2 10:53, 20 February 2008 (EST)

--Ronald_J._Fehd macro.maven == the radical programmer