<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Only error message show from log file in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Read-the-SAS-log-files-and-showing-error-message-in-a-particular/m-p/909729#M40710</link>
    <description>&lt;P&gt;Dear Team,&lt;/P&gt;
&lt;P&gt;Please suggest, How to show the failed job and error or warning message in SAS EG and store it in a table by flow name and error message.&lt;/P&gt;
&lt;P&gt;Log files are stored on the server.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;read all log files which are in FLOWNAME_TABLENAME_YEAR_MONTH_DAY_HOUR_MINUTES_SECONDS.Log&lt;/P&gt;
&lt;P&gt;Extract the log files by flow name, table name, year, month, and day, and all the times part.log&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Shakti&lt;/P&gt;</description>
    <pubDate>Wed, 27 Dec 2023 04:58:58 GMT</pubDate>
    <dc:creator>Shakti_Sourav</dc:creator>
    <dc:date>2023-12-27T04:58:58Z</dc:date>
    <item>
      <title>Read the SAS .log files and showing error message in a particular Table</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Read-the-SAS-log-files-and-showing-error-message-in-a-particular/m-p/909690#M40704</link>
      <description>&lt;P&gt;Dear Team,&lt;/P&gt;
&lt;P&gt;I am trying to read the all &lt;STRONG&gt;.log&lt;/STRONG&gt; files from the server and show the error message and flow name in a table.&lt;/P&gt;
&lt;P&gt;The scheduled flow format is in a server like &lt;STRONG&gt;FLOWNAME_YEAR_MONTH_DATE_HOUR_MINUTES_SECOND.log&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have mentioned a code for reference.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Shakti_Sourav_1-1703592509934.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92072i6DA09964F6DD818F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Shakti_Sourav_1-1703592509934.png" alt="Shakti_Sourav_1-1703592509934.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the above code, I want to the current year, month, and day, And want to extract the scheduled_flow and Table name from another table dynamically which is in the Work library.&lt;/P&gt;
&lt;P&gt;then after filtering the year and monthly basis of log files store it in a table. t&lt;/P&gt;
&lt;P&gt;The table format is,&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Flow Name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Table Name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Error Message&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: In the code, Mentioned&amp;nbsp;&lt;STRONG&gt;*&lt;/STRONG&gt; means, its refers to the rest of time part.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please suggest, How to do extract the log files dynamically with current date ?&lt;/P&gt;
&lt;P&gt;extract the flowName_tableName_year_month_day_whatever_time as it is ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me know, If you find any issues.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Shakti Sourav&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Dec 2023 12:18:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Read-the-SAS-log-files-and-showing-error-message-in-a-particular/m-p/909690#M40704</guid>
      <dc:creator>Shakti_Sourav</dc:creator>
      <dc:date>2023-12-26T12:18:37Z</dc:date>
    </item>
    <item>
      <title>Re: Read the SAS .log files and showing error message in a particular Table</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Read-the-SAS-log-files-and-showing-error-message-in-a-particular/m-p/909696#M40705</link>
      <description>&lt;P&gt;Do you mean that the file names look like:&lt;/P&gt;
&lt;PRE&gt; FLOWNAME_2023_12_23_13_01_23.log&lt;/PRE&gt;
&lt;P&gt;If so why are you looking for filenames like:&lt;/P&gt;
&lt;PRE&gt;XXXXXXX_2023.12.23*.log&lt;/PRE&gt;
&lt;P&gt;Either way you should be able to generate a the pattern with the day of the year part easily enough.&amp;nbsp; To generate periods use the YYMMDDP10. format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let date=%sysfunc(date(),yymmddp10.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To convert to underscores use TRANSLATE() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let date=%sysfunc(translate(&amp;amp;date),_,.));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then your data step code should be simple.&amp;nbsp; I am not sure what you want to READ from the file, so fill that part in yourself.&amp;nbsp; Keep the full filename (or at least the time of day part) in case the job ran more than one on the day of interest.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile "&amp;amp;topdir/&amp;amp;flow._&amp;amp;table._&amp;amp;date*.log" filename=fname .... ;
  input .... ;
  flow = "&amp;amp;flow";
  table = "&amp;amp;table";
  date = input("&amp;amp;date",yymmdd10.);
  format date yymmdd10.;
  filename = fname;
  ....
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Dec 2023 18:11:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Read-the-SAS-log-files-and-showing-error-message-in-a-particular/m-p/909696#M40705</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-12-26T18:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: Read the SAS .log files and showing error message in a particular Table</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Read-the-SAS-log-files-and-showing-error-message-in-a-particular/m-p/909728#M40706</link>
      <description>&lt;P&gt;Thanks, Tom for your quick reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The scheduled flow name looks like &lt;STRONG&gt;FlowName_TableName_Year_Month_Day_Hour_Minutes_Seconds&lt;/STRONG&gt; in the Server.&lt;/P&gt;
&lt;P&gt;I have mentioned one example for your clarity,&lt;/P&gt;
&lt;P&gt;In the server, I have the same flow and table name in different Hours, Minutes, and Seconds. so Want to read the flow, tablename, year wise all the log files then extract the only error or warning messages.&lt;/P&gt;
&lt;P&gt;Ex-&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Actually on the Server,&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;FLOWNAME_TABLENAME_2023_12_27_08_20_02.log&lt;/P&gt;
&lt;P&gt;FLOWNAME_TABLENAME_2023_12_27_02_30_10.log&lt;/P&gt;
&lt;P&gt;FLOWNAME_TABLENAME_2023_12_26_08_20_02.log&lt;/P&gt;
&lt;P&gt;FLOWNAME_TABLENAME_2023_12_26_02_30_10.log&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Want,&amp;nbsp;&lt;/STRONG&gt;Current day month year wise all the log files.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FLOWNAME_TABLENAME_2023_12_27_08_20_02.log&lt;/P&gt;
&lt;P&gt;FLOWNAME_TABLENAME_2023_12_27_02_30_10.log&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;format is&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;FlowName_TableName_Year_Month_Day_Hour_Minutes_Seconds.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;I&amp;nbsp;want to&amp;nbsp;read all the log files by FlowName, Table_name, and current day and Year and Month wise.&lt;/P&gt;
&lt;P&gt;I have tried the * mark to read the all the time part files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Shakti&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2023 04:49:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Read-the-SAS-log-files-and-showing-error-message-in-a-particular/m-p/909728#M40706</guid>
      <dc:creator>Shakti_Sourav</dc:creator>
      <dc:date>2023-12-27T04:49:19Z</dc:date>
    </item>
    <item>
      <title>Only error message show from log file</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Read-the-SAS-log-files-and-showing-error-message-in-a-particular/m-p/909729#M40710</link>
      <description>&lt;P&gt;Dear Team,&lt;/P&gt;
&lt;P&gt;Please suggest, How to show the failed job and error or warning message in SAS EG and store it in a table by flow name and error message.&lt;/P&gt;
&lt;P&gt;Log files are stored on the server.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;read all log files which are in FLOWNAME_TABLENAME_YEAR_MONTH_DAY_HOUR_MINUTES_SECONDS.Log&lt;/P&gt;
&lt;P&gt;Extract the log files by flow name, table name, year, month, and day, and all the times part.log&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Shakti&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2023 04:58:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Read-the-SAS-log-files-and-showing-error-message-in-a-particular/m-p/909729#M40710</guid>
      <dc:creator>Shakti_Sourav</dc:creator>
      <dc:date>2023-12-27T04:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: Read the SAS .log files and showing error message in a particular Table</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Read-the-SAS-log-files-and-showing-error-message-in-a-particular/m-p/909747#M40708</link>
      <description>&lt;P&gt;If I understand what you wrote right then you've got already a Work table with all the log files. All you're missing is to extract info/sub-strings from these log names so you can filter on them to then use this sub-set as input to some log analyze program. If so then below self contained sample code will hopefully give you all the guidance/ideas you need.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* create sample "log" files and dataset with all path and name of these log files */
%let path=%sysfunc(pathname(work));
data _null_;
  file "&amp;amp;path\FLOWNAME_TABLENAME_2023_12_27_08_20_02.log";
  put 'some log message';
  file "&amp;amp;path\FLOWNAME_TABLENAME_2023_12_27_02_30_10.log";
  put 'some log message'/ 'line 2';
  file "&amp;amp;path\FLOWNAME_TABLENAME_2023_12_26_08_20_02.log";
  put 'some log message';
  file "&amp;amp;path\FLOWNAME_TABLENAME_2023_12_26_02_30_10.log";
  put 'some log message';
run;

data log_list;
  infile datalines truncover;
  input log $1000.;
  log=cats("&amp;amp;path\",log);
  
  length 
    flowname $100
    tablename $32
    flow_dttm 8
    _flow_dttm_c $15
    ;
  format flow_dttm datetime20.;

  _basename=scan(log,-1,'\/');
  flowname=scan(_basename,1,'_');
  tablename=scan(_basename,2,'_');

  _flow_dttm_c=prxchange('s/^.+(\d\d\d\d)_(\d\d)_(\d\d)_(\d\d)_(\d\d)_(\d\d)\.log/$1$2$3T$4$5$6/',1,strip(_basename));
  flow_dttm=input(_flow_dttm_c,b8601dt15.);
  drop _:;
  datalines;
FLOWNAME_TABLENAME_2023_12_27_08_20_02.log
FLOWNAME_TABLENAME_2023_12_27_02_30_10.log
FLOWNAME_TABLENAME_2023_12_26_08_20_02.log
FLOWNAME_TABLENAME_2023_12_26_02_30_10.log
;

/* read logs and scan for words or patterns */
data log_scan;
  set log_list;
  do until(done);
    infile dummy filevar=log end=done truncover;
    input log_line $128.;
    /*** and here you scan your log ***/
    /*if find(.....) then output;*/
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2023 10:51:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Read-the-SAS-log-files-and-showing-error-message-in-a-particular/m-p/909747#M40708</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-12-27T10:51:50Z</dc:date>
    </item>
    <item>
      <title>Re: Only error message show from log file</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Read-the-SAS-log-files-and-showing-error-message-in-a-particular/m-p/909757#M40711</link>
      <description>&lt;P&gt;I moved this in here, where it belongs; please do not start multiple threads dealing with the same issue.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2023 12:39:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Read-the-SAS-log-files-and-showing-error-message-in-a-particular/m-p/909757#M40711</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-12-27T12:39:16Z</dc:date>
    </item>
  </channel>
</rss>

