****************************************************************************************************
****************************************************************************************************
* PROGRAM: ms_logchecker.sas
* Created (mm/dd/yyyy): 09/23/2020
*--------------------------------------------------------------------------------------------------
* Reads in the SAS log and checks for concerning lines that may indicate an issue with program execution.
* - Log checker log = log_checker.log
* - SAS dataset = log_checker
* - LogDir = The directory (full path) containing one or more logs to be scanned.
* - LogDir_Out = This is the directory where outputs will be saved.
* - Logname = The name of the specific log file(s) to be scanned, with the ".log" suffix. If specifying more than one log file, separate with a space.
* - Keywords = Additional, user-specified keywords that the tool will scan and report on, separate with a pipe
*--------------------------------------------------------------------------------------------------
* Sentinel Coordinating Center
* info@sentinelsystem.org
***************************************************************************************************;
%macro ms_logchecker(logdir =
%put =====> MACRO CALLED: ms_logchecker v1.0;
/*-----------------------------------------------------------------------------------------------------------
Identify log(s) to read in
-----------------------------------------------------------------------------------------------------------*/
/* Capture run date and time */
call symput('curdate',strip(put(date(),worddate.) || ' @' || put(time(),hhmm.)));
/* Search directory for all log files if no log file is specified */
%if "&logname" = "%str()" %then %do;
length filref $8 file_name $80;
rc = filename(filref, "&logdir");
putlog 'ERROR: (Sentinel) Unable to open directory.';
file_name = dread(dir_id, i);
file_id = mopen(dir_id, file_name);
if file_id > 0 and reverse(compress(file_name)) =: 'gol.'
and index(file_name,"log_checker") = 0 then do;
call symputx('num_logs',strip(put(num_logs,5.)));
select strip(file_name) into :logname separated by ' '
%let num_logs = %sysfunc(countw("&logname",' '));
/*-----------------------------------------------------------------------------------------------------------