%Macro Utl_LogRpt ( Utl_Title=%str(Report on all Notes, Warnings, Errors and inputs and outputs in a SAS Log), /*---------------------------------------------*\ | Inputs | \*---------------------------------------------*/ Utl_InpPth01=d:\log, Utl_InpTxt0101=Utl_TstLog.log, /*---------------------------------------------*\ | Process | \*---------------------------------------------*/ Utl_Gbl=%str(Global Pgm), /*---------------------------------------------*\ | Output file will be the same as input file | | with and extension of .txt for easy viewing | | in notepad on pc | \*---------------------------------------------*/ Utl_OutPth01=%nrstr(&Utl_InpPth01.), /* Same path as input */ /* Same Stem as input but type=Txt */ Utl_OutTxt0101=%scan(&Utl_InpTxt0101.,1,%str(.)).Txt, Utl_Flo=1191233 ) / Des="Report on all Notes, Warnings or Erros in a Log"; /*---------------------------------------------*\ | | | IPO Input / Process / Output | | | | | | Inputs | | ====== | | | | Log from any SAS Program | | | | Process | | ======= | | | | Creates global variablr Pgm | | | | Outputs | | ======= | | | | Analysis of Log ------------------------------------------------| | | | | | ====================================================== | | | | 0 Errors in the Log | | 2 Warnings in the Log | | | | ====================================================== | | | | | | ====================================================== | | Analysis of Errors | | ====================================================== | | | | There are no Errors | | | | | | ====================================================== | | Analysis of Warnings | | ====================================================== | | | | warning: the variable Sex in the drop, keep, or rename list has never been referenced. | | warning: the variable Age in the drop, keep, or rename list has never been referenced. | | | | ====================================================== | | Analysis of LibFil Input and output files | | ====================================================== | | | | note: libname perm refers to the same physical library as perm | | file name=/rtf/t_demog.out | | file name=/rtf/t_demogsex.out | | | | ====================================================== | | Analysis of Permanent Tables | | ====================================================== | | | | note: the data set perm._temp2_ has 126 observations and 10 variables. | | | | ====================================================== | | | | Analysis of SAS Notes | | ====================================================== | | | | note: character values have been converted to numeric values at the places given by: | | note: input data set is empty. | | note: missing values were generated as a result of performing an operation on missing values. | | note: numeric values have been converted to character values at the places given by: | | note: the data set work.demog011 has 0 observations and 7 variables. | | note: the file work._stat1 (memtype=data) was not found, but appears on a delete statement. | | note: variable denom is uninitialized. | | note: variable n is uninitialized. | | note: variable nchar is uninitialized. | | | | | \*---------------------------------------------------------------------------------------------*/ %&utl_Gbl.; %local TxtOut; /*---------------------------------------------*\ | Create global variable Pgm (all caps) | \*---------------------------------------------*/ %let pgm=&sysmacroname.; /*---------------------------------------------*\ | If output flatfile exists then delete it | \*---------------------------------------------*/ %Let TxtOut=%str("&Utl_OutPth01.\&Utl_OutTxt0101."); %if %sysfunc(fexist(&TxtOut.))=0 %then %let urc = %sysfunc(fdelete(&TxtOut.)); /*---------------------------------------------*\ | Echo back inputs and outputs | \*---------------------------------------------*/ filename InpPth "&Utl_InpPth01.\&Utl_InpTxt0101."; %put =============================================; %put Utl_InpPth01 = &Utl_InpPth01 ; %put Utl_InpTxt010 = &Utl_InpTxt0101 ; %put Utl_OutPth01 = %Unquote(&Utl_OutPth01) ; %put Utl_OutTxt0101 = %Unquote(&Utl_OutTxt0101) ; %put =============================================; /*---------------------------------------------*\ | Separate out Erros, Warnings Notes and I/O | \*---------------------------------------------*/ Data LibFil(Keep=ErrWarNte Rename=ErrWarNte=LibFil Label="Input and Output Paths") Err (Keep=ErrWarNte Rename=ErrWarNte=Err Label="Error Records from Log") War (Keep=ErrWarNte Rename=ErrWarNte=War Label="Warning Records from Log") Nte (Keep=ErrWarNte Rename=ErrWarNte=Nte Label="Note Records from Log") Tbl (keep=ErrWarNte PrmDat Rename=ErrWarNte=Tbl Label="Permanent SAS Tables Created") ; Length PrmDat $44 ErrWar $3; /*---------------------------------------------*\ | Counters for Erros Warnings and Notes | \*---------------------------------------------*/ Retain Err War Nte 0; /*---------------------------------------------*\ | Read Log and Count Errors and Warnings | \*---------------------------------------------*/ Do Until ( Done ); infile InpPth length=ll end=done; input @1 ErrWarNte $Varying255. ll; if done then do; file &TxtOut.; Put "======================================================" // Err " Errors in the Log" / War " Warnings in the Log" // "======================================================" / ; end; ErrWarNte=lowcase(ErrWarNte); /*---------------------------------------------*\ | Input and Output files | \*---------------------------------------------*/ if index(ErrWarNte,'were written to file' ) gt 0 or index(ErrWarNte,'lines written to file') gt 0 or index(ErrWarNte,'file name=' ) gt 0 or index(ErrWarNte,'libname' ) gt 0 or index(ErrWarNte,'filename' ) gt 0 or index(ErrWarNte,'physical file') gt 0 or index(ErrWarNte,'file:' ) gt 0 then output LibFil; ErrWar=substr(ErrWarNte,1,3); /*---------------------------------------------*\ | Only examine Error Warnings and Notes | \*---------------------------------------------*/ If ll > 2 and ErrWar in ( 'not' 'war' 'err' ); Select (ErrWar); When ('err') Do; Err=Err+1; Output Err; End; When ('not') Do; Nte=Nte+1; Output Nte; End; When ('war') Do; War=War+1; Output War; End; Otherwise ; end; /* Output Notes 123456789012345678901234567890 NOTE: Table XXXX.XXXXXXXX created, with 4 rows and 3 columns. NOTE: The data set XXXX.XXXXXXXX has 1 observations and 3 variables. NOTE: The data sets XXXX.XXXXXXXX has 1 observations and 3 variables. */ /*---------------------------------------------*\ | Examone Permanent SAS Tables | \*---------------------------------------------*/ if ErrWar='not' then do; PrmDat=' '; select; when (substr(ErrWarNte,7,5) eq 'table' and substr(ErrWarNte,13,4) ne 'work') do; PrmDat=Scan(ErrWarNte,3,' '); output Tbl; end; when (substr(ErrWarNte,7,12) eq 'the data set' and substr(left(substr(ErrWarNte,20,5)),1,4) ne 'work') do; PrmDat=Scan(ErrWarNte,5,' '); output Tbl; end; otherwise ; end; end; else continue; End; Stop; run; /*---------------------------------------------*\ | Report on Errors Warnings Files and Tables | \*---------------------------------------------*/ %macro Utl_LogRpt01(ttl=Analysis of Errors,DatSet=Err); Data _null_; file &TxtOut. Mod; put / "======================================================" / " &Ttl. " / "======================================================" / ; Do until ( Done ); Set &DatSet. End=done; put &DatSet.; End; Done=0; Stop; run; %Mend Utl_LogRpt01; %Utl_LogRpt01(ttl=Analysis of Errors, DatSet=Err); %Utl_LogRpt01(ttl=Analysis of Warnings,DatSet=War); %Utl_LogRpt01(ttl=Analysis of LibFil, DatSet=LibFil); %Utl_LogRpt01(ttl=Analysis of Permanent Tables, DatSet=Tbl); Run; /*---------------------------------------------*\ | Detailed analysis of the Notes | \*---------------------------------------------*/ Data Ntesel(Keep=Tag Nte); Length Tag $64; set Nte; /*---------------------------------------------*\ | Keep only the first most detailed match | | This gives us the possibility of more | | detailed analysis, not used here | \*---------------------------------------------*/ Array Notes{315} $64 ( " 0 observations rewritten, 0 observations added and 0 observations deleted" " 0 lines" " 0 observations" " 0 records" " 0 rows" " 0 obs" "%to value of" "abnormally terminated" "access denied" "allowed" "already been defined" "ambiguous" "apparent invocation" "apparent symbolic" "appears as text" "are not allowed" "argument 1" "argument 2" "argument 3" "assumed" "assuming" "at least" "but appears on" "but is not" "but no" "by-group" "cannot be accessed" "cannot be deleted" "cannot be found" "cannot be loaded" "cannot be set" "cannot be" "cannot open" "cartesian" "central parameter" "character in one" "clause has been augmented" "clause references" "cli error" "closing" "columns were too wide" "condition in the" "conflicting attributes" "contain no data in common" "contain unequal" "contains 1 variable" "convert" "converted to" "converted" "could not be fit" "could not be found" "could not be loaded" "could not be written" "could not be" "could not" "creates a common" "default estimation" "default style will be used instead" "defined as both" "did not satisfy" "differ" "different data types" "division by zero" "does not exist" "does not have enough arguments" "does not match" "doesn't have" "double-dash" "due to a" "due to errors" "due to looping" "dummy macro" "ellipsoid centered" "end of macro" "end-of-record" "ending execution" "enter run" "error" "errorabend" "errorcheck=strict" "errors noted" "estimated autoregression parameter" "examine fields" "exceed" "exceeds 8 characters" "execution terminated" "execution terminating" "expected" "expecting" "experimental release" "export cancelled" "expression has no" "extraneous information" "extraneous" "failed to converge" "failed to load" "failed to" "fatal" "firstobs option >" "firstobs option" "generic critical" "groups are not created" "hanging" "has 0 observations" "has _type_" "has a null" "has already been defined" "has already been set" "has already been" "has already" "has become more" "has been reduced" "has been transformed" "has changed" "has different lengths" "has exceeded" "has multiple" "has never been" "has no condition" "has not been dropped" "has not been" "has too few" "have been detected" "ignored" "ignoring" "illegal" "included in the" "incomplete" "incorrect" "input data set is empty" "input distances have been squared" "input empty" "insufficient" "invalid" "is also a dataset" "is ambiguous" "is before the starting" "is included" "is invalid" "is less than or equal" "is less than" "is not a valid" "is not allowed" "is not assigned" "is not greater than" "is not in effect" "is not in" "is not on file" "is not recognized" "is not sorted" "is not valid" "is obsolete" "is sequential" "it is used out" "is obsolete" "labels differ" "length of numeric" "limit set by" "list empty" "lost card" "mathemat" "mathematical operations" "may be incomplete" "may be longer" "may not be as expected" "merge statement has more than" "merge statement" "missing close parentheses" "missing equals sign" "missing on every" "missing semicolon" "missing values" "missing" "mixed engine types" "model contains" "more positional" "multiple lengths" "multiple optimal" "multiple vertical" "multiple" "must be character" "must be entered" "must be followed" "must be given" "must be invoked" "must have appeared" "must precede" "no body file" "no body" "no by" "no cards" "no data set" "no data sets qualify" "no data" "no effect" "no expression" "no file" "no formats found" "no keep" "no libraries" "no logical assign" "no logical" "no longer exists" "no matching" "no non-missing" "no observations" "no output destinations active" "no output produced" "no output" "no rows were selected" "no rows" "no shape" "no variables found" "no variables specified" "no variables" "none of the options" "nor a valid" "not acceptable" "not adjusted" "not all" "not allow character" "not be included" "not be performed" "not currently licensed" "not found" "not in a valid" "not in effect" "not licensed" "not on input data set" "not processed" "not recognized" "not replaced because" "not resolved" "not valid for import" "not valid" "not written" "null where" "numeric in one" "obs=0" "observations not" "obsolete" "occurred on module" "offline" "one or more lines may be longer" "operand was found in" "option value" "parenthesis for" "previous errors" "proc sql statements are executed immediately" "product not found" "product with which" "quoted string" "recursion" "recursive" "reference" "references the data set being updated" "refers to the same" "refers to" "repeat" "request ignored" "required operator not found" "requires a numeric" "requires compatible" "right-hand" "sas set option obs=0" "sas went" "scale parameter was held fixed" "shifted" "starting variable" "statement has been deleted" "statement needs" "statement syntax" "statement transforms" "statistics are mean corrected" "statistics requested" "stop" "stopped" "subroutine" "syntax for this" "the chi-square is small" "too long" "too many array subscripts" "too small" "too wide" "trying to use" "unable to initialize" "unable to" "unable" "unbalanced" "unclosed" "undeclared" "undetermined" "uninitialized" "unknown" "unrecognized" "unref" "unresolved" "violation" "was disabled" "was misspelled as" "was not created" "was not defined" "was not found" "was not replaced" "went to a new line" "were excluded" "will be assumed" "will be used" "will not be" "will not load" "will stop executing" "within the range" "you can only" "your request" "zero elements" ); Tag=' '; /*---------------------------------------------*\ | Only report first match | \*---------------------------------------------*/ Do i=1 to dim(Notes) Until ( Tag ne ' '); if index(Trim(left(Nte)),trim(Notes{i})) > 0 then do; Tag=trim(left(Notes{i})); output; end; End; /*---------------------------------------------*\ | Do not report non matches | \*---------------------------------------------*/ If trim(left(Tag)) eq ' ' then return; run; /*---------------------------------------------*\ | Remove duplicate Notes | | Should rerrun and recheck | \*---------------------------------------------*/ proc sort data=NteSel out=NteSel1 nodupkey; by Nte; run; Data _null_; file &TxtOut. Mod; set NteSel1; If _n_ =1 then put "======================================================" // " Analysis of SAS Notes " / "======================================================" / ; put Nte; run; proc printto;run; %GoTo Skp; %skp: %Mend Utl_LogRpt; %Utl_LogRpt;