<?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 Re: How to extract sas log and still have it on sas program in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-extract-sas-log-and-still-have-it-on-sas-program/m-p/514925#M32569</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/150360"&gt;@rodrichiez&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;But I;m still haven't found solution for my 2nd question.
&lt;P class="1542747886079"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;&lt;FONT color="#ff0000" face="Consolas"&gt;The&lt;/FONT&gt;&lt;FONT face="Consolas"&gt; second approach is how could I do for just to send the email when an error is found:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="1542747886079"&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You can check SYSRC and SYSCC.&amp;nbsp; Also automatic variables&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;AUTOMATIC SYSERRORTEXT 180-322: Statement is not valid or it is used out of proper order.
AUTOMATIC SYSWARNINGTEXT Data set WORK.WANT was not replaced because this step was stopped.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 20 Nov 2018 21:08:34 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2018-11-20T21:08:34Z</dc:date>
    <item>
      <title>How to extract sas log and still have it on sas program</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-extract-sas-log-and-still-have-it-on-sas-program/m-p/514752#M32551</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need some help, I am building a code that extract errors from sas log and send it out by email, by now the program is working good but I need to do some adjustments. The first one is&amp;nbsp;that I need to have the log both in sas program and in the external file, I put the code below but when I send the log back to the default location the external file return in blank.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC PRINTTO LOG="/sasdata/user_Data/log.log" NEW;
RUN;

PROC PRINTTO; /*Routing back the log the default location*/
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The second approach is how could I do for&amp;nbsp;just to send the email when an error is found:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; filename mylog "/sasdata/user_Data/log.log";       

 filename report "/sasdata/user_Data/reportlog.txt" ;   &lt;BR /&gt;
 data _null_;

   infile mylog;
   input;

   lineno+1;  

   file report;  

   rec = _infile_;

  

   foundit = index(rec,"ERROR:");                                                                                       
                                                                                                                                        
   if ( foundit &amp;gt; 0 ) then do; 

     put lineno " " rec;
   end;

    
                                                                                                                                                                                                                                  
   foundit = index(rec,"ERROR ");                                                                                       
                                                                                                                                        
   if ( foundit &amp;gt; 0 ) then do; 

     rec=substr(rec,foundit);

     if length(rec) &amp;gt; 15 then do;

        tempstr=substr(rec,1,15);
	
        if  (substr(tempstr,7,1) &amp;gt;= "0" and substr(tempstr,7,1) &amp;lt;= "9"
             and index(tempstr,"-") &amp;gt; 0 and index(tempstr,":") &amp;gt; 0    ) then do;

               put lineno " " rec;
	end;
     end;
   end; 

      

   foundit = index(rec,"WARNING:");                                                                                       
                                                                                                                                        
   if ( foundit &amp;gt; 0 ) then do; 

     put lineno " " rec;
   end;

     
                                                                                                                                                                                                                                  
   foundit = index(rec,"WARNING ");                                                                                       
                                                                                                                                        
   if ( foundit &amp;gt; 0 ) then do; 

     rec=substr(rec,foundit);

     if length(rec) &amp;gt; 15 then do;

        tempstr=substr(rec,1,15);
	
        if  (substr(tempstr,9,1) &amp;gt;= "0" and substr(tempstr,9,1) &amp;lt;= "9"
             and index(tempstr,"-") &amp;gt; 0 and index(tempstr,":") &amp;gt; 0    ) then do;

               put lineno " " rec;
	end;
     end;
   end; 


   foundit = index(rec,"ERROR [");                                                                                       
                                                                                                                                        
   if ( foundit &amp;gt; 0 ) then do; 

     put lineno " " rec;
   end;


   foundit = index(rec,"WARN  [");                                                                                       
                                                                                                                                        
   if ( foundit &amp;gt; 0 ) then do; 

     put lineno " " rec;
   end;

run;


/*SEND E-MAIL*/

filename outbox email attach=("/sasdata/u24807_Data/reportlog.txt")

       to='chrodriguez@'
       type='text/html' 
       subject= "Log ETL"
       from='example@';

DATA _NULL_;
FILE outbox;
PUT "&amp;lt;body&amp;gt;";
PUT "&amp;lt;p&amp;gt;Hello, &amp;lt;/p&amp;gt;";
PUT "&amp;lt;p&amp;gt;Program executed with errors.&amp;lt;/p&amp;gt;";
PUT "&amp;lt;p&amp;gt;Regards.&amp;lt;/p&amp;gt;";
PUT "&amp;lt;/body&amp;gt;";

RUN;&lt;BR /&gt;&lt;BR /&gt;Any help will be pretty appreciated.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Nov 2018 14:15:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-extract-sas-log-and-still-have-it-on-sas-program/m-p/514752#M32551</guid>
      <dc:creator>rodrichiez</dc:creator>
      <dc:date>2018-11-20T14:15:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract sas log and still have it on sas program</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-extract-sas-log-and-still-have-it-on-sas-program/m-p/514759#M32552</link>
      <description>&lt;P&gt;For your first question, you are using the wrong tool.&amp;nbsp; PROC PRINTTO can redirect the log to a different destination.&amp;nbsp; But you still only get one copy of the log (as you have seen).&amp;nbsp; To get an additional copy of the log in another location, take a look at the ALTLOG option.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Nov 2018 14:31:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-extract-sas-log-and-still-have-it-on-sas-program/m-p/514759#M32552</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-11-20T14:31:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract sas log and still have it on sas program</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-extract-sas-log-and-still-have-it-on-sas-program/m-p/514762#M32553</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;I'll read about&amp;nbsp;the ALTLOG option.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Nov 2018 14:43:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-extract-sas-log-and-still-have-it-on-sas-program/m-p/514762#M32553</guid>
      <dc:creator>rodrichiez</dc:creator>
      <dc:date>2018-11-20T14:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract sas log and still have it on sas program</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-extract-sas-log-and-still-have-it-on-sas-program/m-p/514873#M32564</link>
      <description>&lt;P&gt;Why not just "replay" it back to the log after you close it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename mylog "/sasdata/user_Data/log.log";       
data _null_; *Replay captured log;
   infile mylog;
   input;
   put _infile_;
   run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Nov 2018 18:00:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-extract-sas-log-and-still-have-it-on-sas-program/m-p/514873#M32564</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2018-11-20T18:00:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract sas log and still have it on sas program</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-extract-sas-log-and-still-have-it-on-sas-program/m-p/514901#M32566</link>
      <description>&lt;P&gt;Hi Astounding. I&amp;nbsp;just read about altlog and seems to be a command for use in the config file not in a sas program. When I try to run the code with -ALTLOG /sasdata/User_Data/log.log , SAS doesn't recognize the command.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Nov 2018 19:10:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-extract-sas-log-and-still-have-it-on-sas-program/m-p/514901#M32566</guid>
      <dc:creator>rodrichiez</dc:creator>
      <dc:date>2018-11-20T19:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract sas log and still have it on sas program</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-extract-sas-log-and-still-have-it-on-sas-program/m-p/514903#M32567</link>
      <description>Hi data_null. I tried your example but code seems to stuck in a loop.</description>
      <pubDate>Tue, 20 Nov 2018 19:18:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-extract-sas-log-and-still-have-it-on-sas-program/m-p/514903#M32567</guid>
      <dc:creator>rodrichiez</dc:creator>
      <dc:date>2018-11-20T19:18:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract sas log and still have it on sas program</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-extract-sas-log-and-still-have-it-on-sas-program/m-p/514922#M32568</link>
      <description>Update: I kept trying the code sent by data_null and actually is working fine. Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10092"&gt;@Data_null_&lt;/a&gt;. But I;m still haven't found solution for my 2nd question.</description>
      <pubDate>Tue, 20 Nov 2018 20:54:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-extract-sas-log-and-still-have-it-on-sas-program/m-p/514922#M32568</guid>
      <dc:creator>rodrichiez</dc:creator>
      <dc:date>2018-11-20T20:54:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract sas log and still have it on sas program</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-extract-sas-log-and-still-have-it-on-sas-program/m-p/514925#M32569</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/150360"&gt;@rodrichiez&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;But I;m still haven't found solution for my 2nd question.
&lt;P class="1542747886079"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;&lt;FONT color="#ff0000" face="Consolas"&gt;The&lt;/FONT&gt;&lt;FONT face="Consolas"&gt; second approach is how could I do for just to send the email when an error is found:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class="1542747886079"&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You can check SYSRC and SYSCC.&amp;nbsp; Also automatic variables&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;AUTOMATIC SYSERRORTEXT 180-322: Statement is not valid or it is used out of proper order.
AUTOMATIC SYSWARNINGTEXT Data set WORK.WANT was not replaced because this step was stopped.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Nov 2018 21:08:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-extract-sas-log-and-still-have-it-on-sas-program/m-p/514925#M32569</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2018-11-20T21:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract sas log and still have it on sas program</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-extract-sas-log-and-still-have-it-on-sas-program/m-p/515087#M32575</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;&amp;nbsp;Ok, I'll&amp;nbsp;search&amp;nbsp;about it. But I was thinking in add to the code something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt; &lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt; foundit &amp;lt;= &lt;SPAN class="token number"&gt;0&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; do&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; 
&lt;SPAN class="token punctuation"&gt;   break;&lt;/SPAN&gt;
   end&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Yet I don't know if there is something&amp;nbsp;similar to&amp;nbsp;break&amp;nbsp;in SAS to stop job execution.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2018 13:48:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-extract-sas-log-and-still-have-it-on-sas-program/m-p/515087#M32575</guid>
      <dc:creator>rodrichiez</dc:creator>
      <dc:date>2018-11-21T13:48:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract sas log and still have it on sas program</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-extract-sas-log-and-still-have-it-on-sas-program/m-p/515568#M32586</link>
      <description>Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10092"&gt;@Data_null_&lt;/a&gt; . I have been reading about it and I have done a significant advance to accomplish what I want using SYSERR and SYSCC.</description>
      <pubDate>Fri, 23 Nov 2018 14:58:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-extract-sas-log-and-still-have-it-on-sas-program/m-p/515568#M32586</guid>
      <dc:creator>rodrichiez</dc:creator>
      <dc:date>2018-11-23T14:58:33Z</dc:date>
    </item>
  </channel>
</rss>

