Advertisement
Guest User

Untitled

a guest
Jul 7th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SAS 25.87 KB | None | 0 0
  1. %macro ut_sas8lchk(logfile=_default_,logref=_default_,outfile=_default_,
  2.  debug=_default_);
  3.   /*soh*****************************************************************
  4.    DESCRIPTION              : The ut_sas8lchk is a platform independent
  5.                               macro that scans the SAS log for
  6.                               occurrences of certain text
  7.                               messages (e.g. ERROR, WARNING, etc. It
  8.                               then produces a report (detail and
  9.                               summary) of the findings.
  10.    SOFTWARE/VERSION#        : SAS V8
  11.  
  12.    INPUT                    : SAS log file to be scanned is automatic
  13.                               on MVS(i.e. no need to specify the
  14.                               filename) and user supplied on W2K.
  15.    OUTPUT                     MS Windows -
  16.                                Output report written to PRINT destination.
  17. ------------------------------------------------------------------------
  18.   Parameters:
  19.    Name     Type     Default  Description and Valid Values
  20.    -------- -------- -------- ------------------------------------------
  21.    LOGFILE  optional          Full name of a file that contains a
  22.                                SAS log
  23.    LOGREF   optional          Fileref previously defined by a FILENAME
  24.                                statement that points to a file
  25.                                containing a SAS log
  26.    OUTFILE  optional          The name of file to write the report to.
  27.                                If this is not specified then the report
  28.                                will be written to the print file.
  29.                                OUTPUT to PDS members is not supported
  30.    DEBUG    required 0        %ut_logical value specifying whether debug
  31.                                mode is on or off
  32. ------------------------------------------------------------------------
  33.   Usage Notes:
  34.         If neither LOGFILE nor LOGREF are specified then the contents of
  35.         the log window in display manager is scanned by this macro.
  36.        
  37. ------------------------------------------------------------------------
  38.   Assumptions:
  39.   In MS Windows, a SAS configuration setting can cause problem with
  40.    the use of the DM command that this macro uses.  This applies when
  41.    running SAS in display manager mode when your program uses the ODS
  42.    statment.  To resolve the problem, start SAS display manager, click
  43.    on "Tools ... Options ... Preferences".  When the resulting dialog
  44.    box appears, click on "Results".  At the bottom of this dialog box
  45.    select "Preferred web browser" in the "View results using:" section.
  46.    If "Internal browser" is selected then SAS will not be able to
  47.    evaluate the contents of the log window when you call this macro
  48. ----------------------------------------------------------------------
  49.   Typical Macro Call(s) and Description:
  50.   MSWindows - %ut_sas8lchk(logfile=h:\myprogram.log)
  51.  
  52.         fileref mylog 'h:\myprogram.log';
  53.   MSWindows - %ut_sas8lchk(logref=mylog)
  54.  
  55.         MSWindows - %ut_sas8lchk    in display manager
  56.  
  57. -----------------------------------------------------------------------
  58.                      BROAD-USE MODULE HISTORY
  59.   Ver#  Author           Description
  60.   ----  ---------------  ----------------------------------------------
  61.                      22 Strings to search for:
  62.                 1    ARGUMENT TO FUNCTION
  63.                 2    DIVISION BY ZERO DETECTED
  64.                 3    ENDSAS
  65.                 4    ERROR
  66.                 5    FORMAT WAS TOO SMALL FOR THE NUMBER TO BE PRINTED
  67.                 6    INVALID NUMERIC DATA
  68.                 7    LOST CARD
  69.                 8    MATHEMATICAL OPERATIONS COULD NOT BE PERFORMED
  70.                 9    MISSING VALUES WERE GENERATED
  71.                10    MORE THAN ONE DATA SET WITH REPEATS OF BY VALUES
  72.                11    NOT FOUND
  73.                12    NOT PREVIOUSLY
  74.                13    NOTE: FORMATTED VALUES OF
  75.                14    ONE OR MORE LINES WERE TRUNCATED
  76.                15    SAS WENT TO A NEW LINE
  77.                16    SHIFTED BY THE "BEST" FORMAT
  78.                17    UERROR
  79.                18    UNINITIALIZED
  80.                19    UWARNING
  81.                20    VALUES HAVE BEEN CONVERTED TO
  82.                21    WARNING
  83.                22    _ERROR_=1
  84.                          Reports UWARNING separately from WARNING
  85.                          Reports ERROR and WARNING only when they are
  86.                           upper case in the log file and they are the
  87.                           first word in the line
  88.                          Added parameter OUTFILE to allow user to
  89.                           redirect the report to any file.
  90.                          Improved header lines:
  91.                           Reports number of message strings found in
  92.                            addition to the number of lines, in case
  93.                            more than one string is found in one line
  94.                           Displays physical path of scanned log file
  95.                           Displays userid of windows user (previously
  96.                            displayed only for MVS
  97.                          Sort list of strings found by descending count
  98.                          Changed the way options are restored, using
  99.                           one macro variable instead of 10
  100.                          Added message when both LOGREF and LOGFILE
  101.                           have been specified in the call to the macro
  102.                          Clarified message when neither LOGREF nor
  103.                           LOGFILE were specified in the macro call
  104.                          Changed macro names to make it more clear
  105.                           altlog1 = altlog1_ddname_path
  106.                           altlog2 = log_file_path
  107.                          Limited the number of log lines with bad
  108.                           strings that are reported to 1000 when
  109.                           running in display manager
  110.                          Added Found flag to summary to make it easier
  111.                           to see the non-zero counts of bad messages
  112.                          Added message when no bad messages found stating
  113.                           no searched messages found
  114.                          Changed format of warning to conform to
  115.                           ut_errmsg
  116.                          Enhanced header comment
  117.                          Added UNOTE when both LOGFILE and LOGREF are
  118.                           specified in call to the ut_sas8lchk
  119.                          Clears title and footnote lines in output and
  120.                           restores them at the end of the macro.
  121.                           Thus, the report will not have pre-existing
  122.                           titles and footnotes but the titles and
  123.                           footnotes will be the same after the macro
  124.                           call as they were before the macro call.
  125.                          Set option nodate
  126.                          Verifies that log file can be read.  If not,
  127.                           then a message is displayed indicating the
  128.                           log file was not checked.
  129. **eoh******************************************************************/
  130. %if %bquote(%upcase(&logfile)) = %upcase(_default_) %then
  131.  %let logfile =;
  132. %if %bquote(%upcase(&logref)) = %upcase(_default_) %then
  133.  %let logref =;
  134. %if %bquote(%upcase(&outfile)) = %upcase(_default_) %then
  135.  %let outfile =;
  136. %if %bquote(%upcase(&debug)) = %upcase(_default_) %then
  137.  %let debug = 0;
  138. %if %sysfunc(indexw(%str(Y T YES TRUE  ON  OUI JA),%upcase(&debug)))
  139.  %then %let debug = 1;
  140. %else %if %sysfunc(indexw(%str(N F NO  FALSE OFF NON NEIN),
  141.  %upcase(&debug))) %then %let debug = 0;
  142. %if &debug ^= 1 & &debug ^= 0 %then %do;
  143.   %put UNOTE(ut_sas8lchk):
  144.    INVALID LOGICAL VALUE OF DEBUG = %nrbquote(&debug);
  145.   %let debug = 0;
  146. %end;
  147. %local options checklog lookfors mvs_sas8lchk_entry altlog1_ddname_path
  148.  log_file_path rc i numtitles numfootnotes fid rc;
  149. %*---------------------------------------------------------------------;
  150. %*                                                                     ;
  151. %* Save original values of changed options.                            ;
  152. %*                                                                     ;
  153. %*---------------------------------------------------------------------;
  154. %let options = %sysfunc(getoption(formdlim));
  155. %if %bquote(&options) ^= %then %let options = formdlim="&options";
  156. %let options = &options
  157.  %sysfunc(getoption(center))
  158.  %sysfunc(getoption(caps))
  159.  %sysfunc(getoption(sgen))
  160.  %sysfunc(getoption(pageno,keyword))
  161.  %sysfunc(getoption(date))
  162.  %sysfunc(getoption(notes))
  163.  %sysfunc(getoption(mprint))
  164.  %sysfunc(getoption(source))
  165.  %sysfunc(getoption(source2))
  166.  %sysfunc(getoption(mlogic))
  167. ;
  168. %if ^ &debug %then %do;
  169.   options nomprint nosource nosource2 nomlogic nonotes;
  170. %end;
  171. options FORMDLIM='-' nocenter nosgen pageno=1 nodate;
  172. *======================================================================;
  173. * Save pre-existing titles and foonotes for later restoration;
  174. *  and clear all title and footnote lines;
  175. *======================================================================;
  176. proc sql;
  177.   create table _cltitles as select * from dictionary.titles;
  178. quit;
  179. %let numtitles = 0;
  180. %let numfootnotes = 0;
  181. data _null_;
  182.   if eof then do;
  183.     call symput('numtitles',trim(left(put(title_num,2.0))));
  184.     call symput('numfootnotes',trim(left(put(footnote_num,2.0))));
  185.   end;
  186.   set _cltitles end=eof;
  187.   if type = 'T' then do;
  188.     title_num + 1;
  189.     call symput('title' || trim(left(put(title_num,2.0))),
  190.      'title' || trim(left(put(number,2.0))) || ' ' || trim(text));
  191.   end;
  192.   else if type = 'F' then do;
  193.     footnote_num + 1;
  194.     call symput('footnote' || trim(left(put(footnote_num,2.0))),
  195.      'footnote' || trim(left(put(number,2.0))) || ' ' || trim(text));
  196.   end;
  197. run;
  198. %if &numtitles > 0 %then %do;
  199.   title;
  200. %end;
  201. %if &numfootnotes > 0 %then %do;
  202.   footnote;
  203. %end;
  204. %*---------------------------------------------------------------------;
  205. %* Verify LOGFILE and LOGREF parameters;
  206. %*---------------------------------------------------------------------;
  207. %if %bquote(&logfile) ^= %then %do;
  208.   %if ^ %sysfunc(fileexist(&logfile)) %then %do;
  209.     %put UWARNING(ut_sas8lchk): specified log file does not exist
  210.      &logfile;
  211.     %goto endmac;
  212.   %end;
  213. %end;
  214. %if %bquote(&logref) ^= %then %do;
  215.   %let rc = %sysfunc(fileref(&logref));
  216.   %if &debug %then
  217.    %put UNOTE(ut_sas8lchk): logref fileref (&logref) exist rc=&rc;
  218.   %if &rc < 0 %then %do;
  219.     %put UWARNING(ut_sas8lchk): specified log fileref exists but the
  220.      file it points to does not exist - &logref;
  221.     %goto endmac;
  222.   %end;
  223.   %if &rc > 0 %then %do;
  224.     %put UWARNING(ut_sas8lchk): specified log fileref does not exist
  225.      &logref;
  226.     %goto endmac;
  227.   %end;
  228. %end;
  229. %if %bquote(&logfile) ^= & %bquote(&logref) ^= %then %do;
  230.   %put UNOTE(ut_sas8lchk): LOGFILE and LOGREF parameters have both
  231.    been specified - at most one should be specified;
  232. %end;
  233. *----------------------------------------------------------------------;
  234. *                                                                      ;
  235. * Determine Operating system and assign appropriate                    ;
  236. * output destination.                                                  ;
  237. %*                                                                     ;
  238. %* MVS will write LOG scan report to fileref CHECKLOG                  ;
  239. %* to be viewed in IOF.                                                ;
  240. %* W2K will write report to PRINT fileref.                             ;
  241. *----------------------------------------------------------------------;
  242. %if &sysscp = OS %then %do;
  243.   *--------------------------------------------------------------------;
  244.   *                                                                    ;
  245.   * In MVS, determine if user invoked SAS via the standard SAS8 clist  ;
  246.   * or by using the SAS8LCHK clist. The SAS8LCHK clist                 ;
  247.   * allocates an eyecatcher file with fileref/ddname                   ;
  248.   * altlog1. A non-blank value for this PATHNAME                       ;
  249.   * indicates entry via SAS8LCHK clist, which enables                  ;
  250.   * the automatic SAS log checking and exit. Use of the                ;
  251.   * UT_SAS8LCHK macro is therefore possible in normal SAS8             ;
  252.   * entry.                                                             ;
  253.   *                                                                    ;
  254.   *--------------------------------------------------------------------;
  255.   option caps;
  256.   %let altlog1_ddname_path = %sysfunc(pathname(altlog1));
  257.   *--------------------------------------------------------------------;
  258.   *                                                                    ;
  259.   * If macro variable altlog1_ddname_path is blank, then the user      ;
  260.   * is using the std SAS8 clist. Otherwise, the user                   ;
  261.   * is using the SAS8LCHK clist. If they are using the                 ;
  262.   * SAS8 clist, then allow use of the SAS8LCHK macro                   ;
  263.   * just like W2K by using the macro variables                         ;
  264.   * LOGREF or LOGFILE passed by the user.                              ;
  265.   *                                                                    ;
  266.   *--------------------------------------------------------------------;
  267.   %if %bquote(&altlog1_ddname_path) = %then %do;  /* Entry via SAS8   */
  268.     %if %bquote(&logfile) ne %then %do;         /* Use user logfile   */
  269.       filename altlog1 "&logfile" disp=shr;
  270.     %end;
  271.     %let mvs_sas8lchk_entry = 0;
  272.     %let checklog = print;                      /* Output to PRINT    */
  273.   %end;
  274.   %else %do;                                    /* Entry via SAS8LCHK */
  275.     %let mvs_sas8lchk_entry = 1;
  276.     %let checklog = checklog;
  277.   %end;
  278. %end;
  279. %else %if &sysscp = WIN %then %do;
  280.   %if %bquote(&logfile) ^=  %then %do;
  281.     filename altlog1 "&logfile";
  282.   %end;
  283.   %let checklog = print;
  284.   %let mvs_sas8lchk_entry = 0;
  285. %end;
  286. %else %do;
  287.   %put UNOTE(ut_sas8lchk): operating system not recognised = &sysscp;
  288.   %goto endmac;
  289. %end;
  290. %*---------------------------------------------------------------------;
  291. %*                                                                     ;
  292. %* If LOGREF and LOGFILE are both absent, then write log window to     ;
  293. %* a temporary file for input to the macro. This action is             ;
  294. %* only necessary if the user is NOT using the SAS8LCHK clist          ;
  295. %* (or batch) on MVS.                                                  ;
  296. %*                                                                     ;
  297. %*---------------------------------------------------------------------;
  298. %if %bquote(&logref) = & %bquote(&logfile) = & ^ &mvs_sas8lchk_entry
  299.  %then %do;
  300.   %if &sysprocessname = %str(DMS Process) %then %do;
  301.     filename _lclchk temp;
  302.     dm log 'file _lclchk replace';
  303.     %let logref = _lclchk;
  304.     %if &debug %then %do;
  305.       filename _lclchk list;
  306.       data _null_;
  307.         infile _lclchk;
  308.         input;
  309.         put 'UNOTE(ut_sas8lchk): debug ' _infile_;
  310.       run;
  311.     %end;
  312.   %end;
  313.   %else %do;
  314.     %put UNOTE(ut_sas8lchk): neither LOGFILE nor LOGREF parameters
  315.      have been specified - one must be specified when not executing
  316.      in display manager;
  317.     %goto endmac;
  318.   %end;
  319. %end;
  320. %if %bquote(&logref) ^= %then
  321.  %let log_file_path = %sysfunc(pathname(&logref));
  322. %else %if %bquote(&logfile) ^= %then %let log_file_path = &logfile;
  323. %*=====================================================================;
  324. %* Verify that the log file can be opened in read mode;
  325. %*=====================================================================;
  326. %if &logref ^= %then %do;     /* Use user logref if supplied */
  327.   %let fid = %sysfunc(fopen(&logref,i));
  328. %end;
  329. %else %do;                    /* else use logfile file       */
  330.   %let fid = %sysfunc(fopen(altlog1,i));
  331. %end;
  332. %if &debug %then %put fid = &fid;
  333. %if &fid > 0 %then %do;
  334.   %let rc = %sysfunc(fclose(&fid));
  335.   %if &debug %then %put close rc=&rc;
  336. %end;
  337. %else %do;
  338.   data _null_;
  339.     %if %bquote(&outfile) = %then %do;
  340.       file &checklog;
  341.     %end;
  342.     %else %do;
  343.       file "&outfile";
  344.     %end;
  345.     date = today();
  346.     time = time();
  347.     put "SAS LOG FILE SCANNED &log_file_path";
  348.     %if &sysscp = OS  %then %do;
  349.       put @3 "Jobname:                   &sysjobid";
  350.     %end;
  351.     put @3 "User                     : &sysuserid";
  352.     put @3 "Date(of SCAN)            : " date date9.;
  353.     put @3 "Time(of SCAN)            : " time time8.0;
  354.     put @3 "Operating System(of SCAN): &sysscp &sysscpl";
  355.     put @3 "SAS Version(of SCAN)     : &sysver";
  356.     put //// @ 20 'Unable to open log file.  Log check not performed.';
  357.     stop;
  358.   run;
  359.   %goto endmac;
  360. %end;
  361. *----------------------------------------------------------------------;
  362. *                                                                      ;
  363. * Create a data set containing things to look for in the log.          ;
  364. *                                                                      ;
  365. * Each text string will be assigned to a macro variable                ;
  366. * (lookfor1, lookfor2, lookfor3, etc).                                 ;
  367. *                                                                      ;
  368. *----------------------------------------------------------------------;
  369. data _clsrchfor;
  370.   length lookfor $ 80. count 8;
  371.   count = 0;
  372.   lookfor='er' || 'ror';                                         output;
  373.   lookfor='war' || 'ning';                                       output;
  374.   lookfor='unin' || 'itialized';                                 output;
  375.   lookfor='mis' || 'sing values were generated';                 output;
  376.   lookfor='uer' || 'ror';                                        output;
  377.   lookfor='more th' || 'an one data set with repeats of BY values';
  378.                                                                  output;
  379.   lookfor='arg' || 'ument to function';                          output;
  380.   lookfor='valu' || 'es have been converted to';                 output;
  381.   lookfor='mathema' || 'tical operations could not be performed';
  382.                                                                  output;
  383.   lookfor = 'lost ' || 'card';                                   output;
  384.   lookfor = 'not' || ' found';                                   output;
  385.   lookfor = 'not' || ' previously';                              output;
  386.   lookfor = '_error_' || '=1';                                   output;
  387.   lookfor = 'end' || 'sas';                                      output;
  388.   lookfor = 'uwar' || 'ning';                                    output;
  389.   lookfor = 'division by' || ' zero detected';                   output;
  390.   lookfor = 'sas went' || ' to a new line';                      output;
  391.   lookfor = 'in' || 'valid numeric data';                        output;
  392.   lookfor = 'On' || 'e or more lines were truncated';            output;
  393.   lookfor = 'format was too' ||' small for the number to be printed';
  394.                                                                  output;
  395.   lookfor = 'shifted' || ' by the ""best"" format';              output;
  396.   lookfor = 'note: formatted values of';                         output;
  397.   stop;
  398. run;
  399. %let lookfors = 0;
  400. data _clsrchfor;
  401.   set _clsrchfor end=last;
  402.   if lookfor ^= ' ';
  403.   lookfor = upcase(lookfor);
  404.   looknum + 1;
  405.   call symput('lookfor' || trim(left(put(looknum,8.0))),
  406.    trim(left(lookfor)));
  407.   if last then call symput('lookfors',trim(left(put(looknum,8.0))));
  408.   lookfor = tranwrd(lookfor,'""BEST""','"BEST"');
  409.   drop looknum;
  410. run;
  411. %if &debug %then %do;
  412.   %put lookfors=&lookfors;
  413.   %do i = 1 %to &lookfors;
  414.     %put lookfor&i=&&lookfor&i;
  415.   %end;
  416.   %put;
  417. %end;
  418. data _cllines (keep=logrec logrecline)
  419.      _clmsg (keep=msg_found logrecline);
  420.   length msg msg_found $80.;
  421.   date = today();
  422.   time = time();
  423.   %if &logref ^= %then %do;     /* Use user logref if supplied */
  424.     infile &logref end=last missover length=lv;
  425.   %end;
  426.   %else %do;                    /* else use logfile file       */
  427.     infile altlog1 end=last missover length=lv;
  428.   %end;
  429.   input @1 logrec $varying132. lv;
  430.   %if &debug %then %do;
  431.     file log;
  432.     if _n_ = 1 then put 'UNOTE(ut_sas8lchk): starting debug list of log file:'/;
  433.     put _infile_;
  434.     if last then put 'UNOTE(ut_sas8lchk): ending debug list of log file:'/;
  435.   %end;
  436.   %if %bquote(&outfile) = %then %do;
  437.     file &checklog;
  438.   %end;
  439.   %else %do;
  440.     file "&outfile";
  441.   %end;
  442.   if _n_ = 1 then do;
  443.     put "SAS LOG FILE SCANNED &log_file_path";
  444.     %if &sysscp = OS  %then %do;
  445.       put @3 "Jobname:                   &sysjobid";
  446.     %end;
  447.     put @3 "User                     : &sysuserid";
  448.     put @3 "Date(of SCAN)            : " date date9.;
  449.     put @3 "Time(of SCAN)            : " time time8.0;
  450.     put @3 "Operating System(of SCAN): &sysscp &sysscpl";
  451.     put @3 "SAS Version(of SCAN)     : &sysver";
  452.     put ;
  453.   end;
  454.   logrecline = _n_;
  455.   badrec = 0;
  456.   *--------------------------------------------------------------------;
  457.   * Scan for er-ror and wa-rning in column 1 only                      ;
  458.   * Scan for other messages anywhere in the log line                   ;
  459.   *--------------------------------------------------------------------;
  460.   %do i = 1 %to &lookfors;
  461.     *------------------------------------------------------------------;
  462.     %bquote(* Message &i;)
  463.     *------------------------------------------------------------------;
  464.     msg = "%substr(&&lookfor&i,1,2)" || "%substr(&&lookfor&i,3)";
  465.     found_at = index(upcase(logrec),trim(msg));
  466.     msg_found = ' ';
  467.     if found_at in (1 2) and ((msg = 'ER' || 'ROR' | msg = 'WAR' || 'NING')
  468.      & upcase(left(logrec)) ^=: 'UER' ||'ROR' &
  469.      upcase(left(logrec)) ^=: 'UWA' || 'RNING')
  470.      then do;
  471.       if index(logrec,trim(msg)) in (1 2) then do;
  472.         msgs_found + 1;
  473.         msg_found = msg;
  474.         if ^ badrec then do;
  475.           recs_found + 1;
  476.           badrec = 1;
  477.           output _cllines;
  478.         end;
  479.       end;
  480.     end;
  481.     else if found_at ge 1 and
  482.      (msg ^= 'ER' || 'ROR' and MSG ^= 'WAR' || 'NING') then do;
  483.       msgs_found + 1;
  484.       msg_found = msg;
  485.       if ^ badrec then do;
  486.         recs_found + 1;
  487.         badrec = 1;
  488.         output _cllines;
  489.       end;
  490.     end;
  491.     if msg_found ^= ' ' then output _clmsg;
  492.   %end;
  493.   if last then do;
  494.     put 'Total log file lines read                                ' _n_;
  495.     if . < recs_found < 1 & . < msgs_found < 1 then
  496.      put 'No searched messages found.';
  497.     else put      'Number of lines containing at least one searched message '
  498.      recs_found / 'Number of searched messages found                        '
  499.      msgs_found // ;
  500.   end;
  501. run;
  502. proc freq data=_clmsg;
  503.   tables msg_found / noprint out=_clmsg_found(keep=msg_found count);
  504. run;
  505. proc sort data = _clsrchfor;
  506.   by lookfor;
  507. run;
  508. %if &debug %then %do;
  509.   proc print data = _clmsg  width=minimum;
  510.     title '(ut_sas8lchk) debug: _clmsg data set';
  511.   run;
  512.   proc print data = _clmsg_found  width=minimum;
  513.     title '(ut_sas8lchk) debug: _clmsg_found data set';
  514.   run;
  515.   proc print data = _clsrchfor  width=minimum;
  516.     title '(ut_sas8lchk) debug: _clsrchfor data set';
  517.   run;
  518.   title;
  519. %end;
  520. data _clmsg_found;
  521.   merge _clsrchfor (rename=(lookfor=msg_found))  _clmsg_found;
  522.   by msg_found;
  523. run;
  524. proc sort data = _clmsg_found;
  525.   by descending count msg_found;
  526. run;
  527. proc printto print=
  528.   %if %bquote(&outfile) = %then %do;
  529.     &checklog
  530.   %end;
  531.   %else %do;
  532.     "&outfile"
  533.   %end;
  534. ;
  535. run;
  536.   proc print noobs data=_clmsg_found label;
  537.     label msg_found='Searched Message'
  538.      count = 'Frequency';
  539.   run;
  540.   data _null_;
  541.     file print;
  542.     if eof & _n_ = 1 then
  543.      put //// @20 'N o    s e a r c h e d    m e s s a g e s    f o u n d  !';
  544.     set _cllines  end=eof;
  545.     %if &sysprocessname = %str(DMS Process) %then %do;
  546.       if _n_ <= 1000 then put @2 'Record=' logrecline '-->' / logrec /;
  547.       else do;
  548.         put // @20 'Further records will not be printed';
  549.         stop;
  550.       end;
  551.     %end;
  552.     %else %do;
  553.       put @2 'Record=' logrecline '-->' / logrec /;
  554.     %end;
  555.   run;
  556. proc printto;
  557. run;
  558. *----------------------------------------------------------------------;
  559. * Check for OS before clearing a fileref. You cannot clear a           ;
  560. * fileref that was assigned via JCL (you will get a warning).          ;
  561. * Only do the FILENAME CLEAR in MVS if it is a non-temp dataset.       ;
  562. * A temporary dataset (i.e. JCL defined) will begin with SYS.          ;
  563. *----------------------------------------------------------------------;
  564. %if &sysscp = OS %then %do;
  565.   %if %substr(%str(&altlog1_ddname_path   ),1,3) ^= SYS %then %do;
  566.     %if %sysfunc(fileref(altlog1)) <= 0 %then %do;
  567.       filename altlog1 clear;
  568.     %end;
  569.   %end;
  570. %end;
  571. %else %if &sysscp = WIN %then %do;
  572.   %if %sysfunc(fileref(altlog1)) <= 0 %then %do;
  573.     filename altlog1 clear;
  574.   %end;
  575. %end;
  576. %endmac:
  577. *----------------------------------------------------------------------;
  578. * Return options to their original value.                              ;
  579. *----------------------------------------------------------------------;
  580. proc datasets lib = work nolist;
  581.   delete _cl:;
  582. run; quit;
  583. %if &sysscp = OS & &sysenv = FORE & &mvs_sas8lchk_entry = 1 %then %do;
  584.   *--------------------------------------------------------------------;
  585.   *                                                                    ;
  586.   * If OS is MVS and environment is foreground,                        ;
  587.   * and we are in the SAS8LCHK clist, then ENDSAS.                     ;
  588.   *                                                                    ;
  589.   *--------------------------------------------------------------------;
  590.   endsas;
  591. %end;
  592. %if &numtitles > 0 %then %do i = 1 %to &numtitles;
  593.   &&title&i;
  594. %end;
  595. %if &numfootnotes > 0 %then %do i = 1 %to &numfootnotes;
  596.   &&footnote&i;
  597. %end;
  598. options &options;
  599. %mend;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement