/* MACRO DETAILS CALL: %logchk(notes, dirname); PARAMETERS SUPPLIED BY USER: dirname = pathname of directory containing .LOG files notes = display NOTES in .LOG files (Y). EXAMPLE MACRO CALL: %logchk(Y, m:\xx\xxx\docs\sas); **************************************************/ %macro logchk(notes, dirname); options nofmterr nosymbolgen mprint nodate pageno=1 ls=132 noxwait; title; title3 "Output from LOGCHK Macro for the &DIRNAME Directory"; footnote; footnote1 "Source: iBRD-Rostrum LOGCHK.SAS (&DATE &TIME)"; data _null_; call symput('direct', "dir &dirname\*.log > c:\temp\dir.lst"); run; /*************************************************************************/ /* Get directory using X Command. Input and pull out the LOG */ /* files. Determine total number of LOG files to be processed. */ /*************************************************************************/ x &DIRECT; data director; format s1 $char43.; infile 'c:\temp\dir.lst'; input s1 $ 1-43; if ^index(s1, 'Directory'); if index(s1, "%upcase(LOG)"); cntr + 1; word = scan(s1,1); call symput('n', trim(left(put(cntr,8.)))); drop s1 cntr; run; /**************************************************************/ /* Loop thru; read in each LOG file, and determine if */ /* any of the desired messages are present. */ /**************************************************************/ %do y = 1 %to &N; data _null_; set director; if _n_ = &Y; call symput('log', trim(left(word))); run; filename log&Y "&DIRNAME\&LOG..log"; data log&Y; infile log&Y end = eof length=len; length logfile $15; input @1 rline & $varying200. len; rline = upcase(rline); logfile = "&LOG..log"; %if %upcase(%substr(&NOTES,1,1)) = Y %then %do; if (index(rline, 'NOTE:')) & ( index(rline, 'MISSING') | index(rline, 'CONVERT') | index(rline, 'ILLEGAL') | index(rline,‘INVALID’) | index(rline, ‘MATHEMAT’)) then output; %end; if index(rline, 'ERROR') | index(rline, 'WARNING:') | index(rline, 'UNINITIAL') | index(rline, 'REFERENC') | index(rline, 'NOT RESOLV') then output; run; %end; /****************************************************************************/ /* Because of the possibility of having too many files opened, we */ /* have to loop thru the LOG files to SET them. First determine */ /* total number of loops to go thru. */ /****************************************************************************/ data _null_; numloops = int(&N/100) + 1*(mod(&N,100) > 0); call symput('nloops', trim(left(put(numloops, 8.)))); run; /***********************************************************/ /* This is where we loop thru to SET the data sets. */ /***********************************************************/ %do x = 1 %to &NLOOPS; %let start = %eval(100*(&X-1)+1); %let fin = %eval(100*&X); %if &FIN > &N %then %let fin = &N; data alllog; set %if &X ne 1 %then %do; alllog %end; %do y = &START %to &FIN; log&Y %end;; run; %end; /******************************/ /* Sort and report results. */ /******************************/ proc sort data=alllog; by logfile; run; proc report data=alllog nofs headline headskip; columns logfile rline; break after logfile/skip; define logfile/order order=data width=15 'LOG File Name'; define rline/display width=100 flow 'Message'; run; %mend;