Hello there SAS community, I was looking for a way to analyze logs and found a MWSUG paper about the topic (MWSUG 2016 - Paper BB18 - SAS Advanced Programming with Efficiency in Mind: A Real Case Study) that was promising; it contains two macros and the first works perfectly but the second appears to be truncated in the paper (page 6); I still tried to solve it but I keep receiving multiple errors indicating there is something missing. The code is this and the macro that gives errors is the second one: %macro log_IO_search(log = , doc = );
%*if not %index(&log, '_') %then %let log = &log.*.log;
data _null_;
length logname f logline $200;
infile "&log" filename=f end=done;
file "&doc";
logname=f;
if logname ne lag(logname) then do;
if line then put line "lines read";
put //'-----' logname '------';
line=0;
end;
input ;
line + 1;
output = index(_infile_, 'NOTE: the data set') and
not index(_infile_, '--NOTE:')
or
index(_infile_, 'were written to the file')
;
input = index(_infile_, 'read from') or index(_infile_, 'WHERE ');
time = index(_infile_, ' time');
logline = _infile_;
keep = ifc(input, 'INPUT ', 'OUTPUT');
keep = ifc(input, keep, 'TIME ');
if input or output or time then put keep logline;
if done then put line "lines read";
run;
%mend log_IO_search;
%let log = .log;
%let name_log = ;
%let doc = ;
%log_IO_search(log = &log , doc = &doc);
/****************************/
*step 2;
*log = file_name from step 1;
*doc = results file;
%macro log_IO_data(log = , doc = );
data log_runtime_messy log_runtime(keep = dsn ntime ctime procdat obs);
length logname f logline $200 dsn $32 PROCDAT $6;
retain dsn obs;
infile "&log" filename=f end=done;
file "&doc"; *optional;
logname = f;
if logname ne lag(logname) then do;
if line then put line "lines read";
put //'-----' logname '------';
line=0;
end;
input @;
if
index(_infile_, 'TIME NOTE: the data set')
or index(_infile_, 'TIME NOTE: DATA statement used (total precess time):')
or index(_infile_, 'TIME NOTE: PROCEDURE SORT used (total precess time):')
or index(_infile_, 'TIME NOTE: PROCEDURE SQL used (total precess time):')
then do;
input /;
ctime = scan(_infile_,4,'');
if index(ctime, ':') then do;
if countc(ctime, ':') = 1 then ctime='0:'||ctime ;
ntime = input(strip(ctime), time11.2);
end;
else ntime=ctime+0;
if PROCDAT='DATA: ' then do;
DATA_TIME+ntime;
DATA_steps+1;
end;
else if PROCDAT='SORT: ' then do;
SORT_TIME+ntime;
SORT_steps+1;
end;
else do;
SQL_TIME+ntime;
SQL_steps+1;
end;
output;
put PROCDAT _infile_ @46 OBS comma10.0 ' ' @60 DSN "---" ntime=mmss8.2; *optional;
end;
else input;
end;
else input;
if done then do;
put DATA_steps " DATA steps -- total process time " DATA_time = time11.2 ; *optional;
put SORT_steps " SORT steps -- total process time " SORT_time = time11.2 ; *optional;
put SQL_steps " SQL steps -- total process time " SQL_time = time11.2 ; *optional;
end;
run;
%mend log_IO_data; I hope you can help me find out what is missing. Thanks a lot
... View more