As the first step in the decommissioning of sasCommunity.org 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 Job Time

From sasCommunity
Jump to: navigation, search

SaveJobTime

See Option TermStmt

 /*name    : SaveJobTime.sas
description: save job time to date-stamped data set
purpose    : automatic logging
usage      : called by option termstmt
config:
-termstmt '%Include "!SASuseSAS\SaveJobTime.sas";'
****   *******/
options nosource nonotes; run;
DATA   _Null_;
retain Testing %eval(0
            or %sysfunc(getoption(Source2))
                               eq SOURCE2  );
if Testing then call execute('options source notes;');
stop;  run;

Data   JobTime;
attrib %*primary keys;
       DateTime   length =   8 format = datetime20.2
       SysId      length =   4
       SysJobId   length =   4
       %*secondary keys;
       Host       length = $20
       UserId     length = $ 4
       %*facts;
       JobTime    length =   8 format = 32.2
       SysIn      length = $80

%*     SysMaxTimeReal    length =   8;
%*     SysMaxTimeCpuUser length =   8;
%*     SysMaxTimeCpuSys  length =   8;
%*     SysMaxMemory      length =   8;

%*     SysUseTimeReal    length =   8;
%*     SysUseTimeCpuUser length =   8;
%*     SysUseTimeCpuSys  length =   8;
%*     SysUseMemory      length =   8;

%*     SysUseSortSize    length =   4;
%*     SysUseSteps       length =   4;
%*     SysUseSumSize     length =   4;
       ;
DateTime = input("%substr(&SysProcessId.,1,16)",hex16.);
SysId    =  %substr(&SysProcessId.,17,4);%*length(9999)==Nusers;
SysJobId =  &SysJobId.;
Host     = "%sysget(computername)";%*Windows environment variable;
UserId   = "&SysUserId.";
JobTime  =  datetime() - DateTime;
SysIn    = "%sysfunc(getoption(SysIn))";
;/********************************
SysUseTimeReal    = peeklong(???);
SysUseTimeCpuUser = peeklong(???);
SysUseTimeCpuSys  = peeklong(???);
SysUseMemory      = peeklong(???);
;/*******************************/
output;
stop;    
run;
%let DatePart  = %sysfunc(datepart(%substr(&SysProcessId.,1,16)x));
%let Year      = %sysfunc(year(&Datepart.));
%let Month     = %sysfunc(putn(&Datepart.,  month2.));
%let Month     = %sysfunc(putn(&Month.   ,      z2.));
%let MonthName = %sysfunc(putn(&Datepart.,monname3.));
%let Day       = %sysfunc(putn(&Datepart.,     day.));
%let Day       = %sysfunc(putn(&Day.     ,      z2.));

Libname             SASlogs '!SASuseLib';
Proc Append  base = SASlogs.Jobs&Year._&Month.&MonthName.&Day.
             data = JobTime;
run; options source notes;
run;

--macro maven == the radical programmer 09:42, 14 August 2007 (EDT)