<?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: Output the SAS Project Log File to an external file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Output-the-SAS-Project-Log-File-to-an-external-file/m-p/734398#M228793</link>
    <description>&lt;P&gt;In each sas program you can use the&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1oardywxmmut7n1pol0zkj5u1ok.htm" target="_self"&gt;proc printto&lt;/A&gt;&amp;nbsp;procedure to output to a unique text file log.&lt;/P&gt;&lt;P&gt;Alternately, you can create a new sas program and preface it with a proc printto procedure and have it run all of your unique sas jobs using&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsglobal/p1s3uhhqtscz2sn1otiatbovfn1t.htm" target="_self"&gt;%include&lt;/A&gt;. Like so:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc printto new log="C:\filepath\log.txt";
run;

%include "C:\filepath\job1.sas";
%include "C:\filepath\job2.sas";
/* repeat as necessary */
%include "C:\filepath\jobn.sas";&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;All the logs from the jobs ran using this sas job will be compiled into your c:\filepath\log.txt file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Of course, that's assuming you are able to avoid using vba in running any of your programs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The new option in the proc printto statement will replace instead of append to the file.&lt;/P&gt;&lt;P&gt;If you need a new log every time, you can have sas generate the txt file with a date.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc printto log = "c:\filepath\log_%sysfunc(today,yymmddn6.).txt";
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Apr 2021 18:30:42 GMT</pubDate>
    <dc:creator>JNR</dc:creator>
    <dc:date>2021-04-15T18:30:42Z</dc:date>
    <item>
      <title>Output the SAS Project Log File to an external file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-the-SAS-Project-Log-File-to-an-external-file/m-p/734269#M228763</link>
      <description>&lt;P&gt;To keep track of the tasks I run during the night, I am trying to find what could be the best way to export the log files for each of my daily projects (each of them containing several SAS Program). I found out about the SAS Project Log recently, which basically summarize the logs from all the programs within a SAS Project.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I discovered&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15089"&gt;@CaseySmith&lt;/a&gt;'s&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;A href="https://communities.sas.com/t5/SAS-Enterprise-Guide/Auto-Purge-Project-Log-in-EG/m-p/436983/highlight/true#M28212" target="_self"&gt;answer&lt;/A&gt;&amp;nbsp;on the SAS Community forum, basically tweaking the .vbs&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;script to save the SAS Project log file to a .txt using the following code:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Set objProjectLog = objProject.ProjectLog
objProjectLog.Clear()

objProjectLog.Enabled = True
strProjectLog = objProjectLog.Text
objProjectLog.SaveAs "c:\temp\projectLog.txt"&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;But&amp;nbsp;I don't know where to add it in my current .vbs script:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class="lang-vb s-code-block hljs vbnet"&gt;&lt;CODE&gt;&lt;SPAN class="hljs-keyword"&gt;Option&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;Explicit&lt;/SPAN&gt;
&lt;SPAN class="hljs-keyword"&gt;Dim&lt;/SPAN&gt; app

&lt;SPAN class="hljs-keyword"&gt;Call&lt;/SPAN&gt; dowork

&lt;SPAN class="hljs-comment"&gt;'shut down the app&lt;/SPAN&gt;
&lt;SPAN class="hljs-keyword"&gt;If&lt;/SPAN&gt; &lt;SPAN class="hljs-built_in"&gt;not&lt;/SPAN&gt; (app &lt;SPAN class="hljs-built_in"&gt;Is&lt;/SPAN&gt; &lt;SPAN class="hljs-literal"&gt;Nothing&lt;/SPAN&gt;) &lt;SPAN class="hljs-keyword"&gt;Then&lt;/SPAN&gt;
    app.Quit
    &lt;SPAN class="hljs-keyword"&gt;Set&lt;/SPAN&gt; app = &lt;SPAN class="hljs-literal"&gt;Nothing&lt;/SPAN&gt;
&lt;SPAN class="hljs-keyword"&gt;End&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;If&lt;/SPAN&gt;


&lt;SPAN class="hljs-keyword"&gt;Sub&lt;/SPAN&gt; dowork()
    &lt;SPAN class="hljs-keyword"&gt;On&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;Error&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;Resume&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;Next&lt;/SPAN&gt;
    &lt;SPAN class="hljs-comment"&gt;'----&lt;/SPAN&gt;
    &lt;SPAN class="hljs-comment"&gt;' Start up Enterprise Guide using the project name&lt;/SPAN&gt;
    &lt;SPAN class="hljs-comment"&gt;'----&lt;/SPAN&gt;
    &lt;SPAN class="hljs-keyword"&gt;Dim&lt;/SPAN&gt; prjName
    &lt;SPAN class="hljs-keyword"&gt;Dim&lt;/SPAN&gt; prjObject

    prjName = &lt;SPAN class="hljs-string"&gt;"C:\Users\kermit\Desktop\Project.egp"&lt;/SPAN&gt;    &lt;SPAN class="hljs-comment"&gt;'Project Name&lt;/SPAN&gt;
      
    &lt;SPAN class="hljs-keyword"&gt;Set&lt;/SPAN&gt; app = CreateObject(&lt;SPAN class="hljs-string"&gt;"SASEGObjectModel.Application.8.1"&lt;/SPAN&gt;)
    &lt;SPAN class="hljs-keyword"&gt;If&lt;/SPAN&gt; Checkerror(&lt;SPAN class="hljs-string"&gt;"CreateObject"&lt;/SPAN&gt;) = &lt;SPAN class="hljs-literal"&gt;True&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;Then&lt;/SPAN&gt;
        &lt;SPAN class="hljs-keyword"&gt;Exit&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;Sub&lt;/SPAN&gt;
    &lt;SPAN class="hljs-keyword"&gt;End&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;If&lt;/SPAN&gt;
    
    &lt;SPAN class="hljs-comment"&gt;'-----&lt;/SPAN&gt;
    &lt;SPAN class="hljs-comment"&gt;' open the project&lt;/SPAN&gt;
    &lt;SPAN class="hljs-comment"&gt;'-----&lt;/SPAN&gt;
    &lt;SPAN class="hljs-keyword"&gt;Set&lt;/SPAN&gt; prjObject = app.Open(prjName,&lt;SPAN class="hljs-string"&gt;""&lt;/SPAN&gt;)
    &lt;SPAN class="hljs-keyword"&gt;If&lt;/SPAN&gt; Checkerror(&lt;SPAN class="hljs-string"&gt;"app.Open"&lt;/SPAN&gt;) = &lt;SPAN class="hljs-literal"&gt;True&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;Then&lt;/SPAN&gt;
        &lt;SPAN class="hljs-keyword"&gt;Exit&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;Sub&lt;/SPAN&gt;
    &lt;SPAN class="hljs-keyword"&gt;End&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;If&lt;/SPAN&gt;
    
        
    &lt;SPAN class="hljs-comment"&gt;'-----&lt;/SPAN&gt;
    &lt;SPAN class="hljs-comment"&gt;' run the project&lt;/SPAN&gt;
    &lt;SPAN class="hljs-comment"&gt;'-----&lt;/SPAN&gt;
    prjObject.run
    &lt;SPAN class="hljs-keyword"&gt;If&lt;/SPAN&gt; Checkerror(&lt;SPAN class="hljs-string"&gt;"Project.run"&lt;/SPAN&gt;) = &lt;SPAN class="hljs-literal"&gt;True&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;Then&lt;/SPAN&gt;
        &lt;SPAN class="hljs-keyword"&gt;Exit&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;Sub&lt;/SPAN&gt;
    &lt;SPAN class="hljs-keyword"&gt;End&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;If&lt;/SPAN&gt;
    
            
    &lt;SPAN class="hljs-comment"&gt;'-----&lt;/SPAN&gt;
    &lt;SPAN class="hljs-comment"&gt;' Save the new project&lt;/SPAN&gt;
    &lt;SPAN class="hljs-comment"&gt;'-----&lt;/SPAN&gt;
    prjObject.Save
    &lt;SPAN class="hljs-keyword"&gt;If&lt;/SPAN&gt; Checkerror(&lt;SPAN class="hljs-string"&gt;"Project.Save"&lt;/SPAN&gt;) = &lt;SPAN class="hljs-literal"&gt;True&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;Then&lt;/SPAN&gt;
        &lt;SPAN class="hljs-keyword"&gt;Exit&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;Sub&lt;/SPAN&gt;
    &lt;SPAN class="hljs-keyword"&gt;End&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;If&lt;/SPAN&gt;
    
    &lt;SPAN class="hljs-comment"&gt;'-----&lt;/SPAN&gt;
    &lt;SPAN class="hljs-comment"&gt;' Close the project&lt;/SPAN&gt;
    &lt;SPAN class="hljs-comment"&gt;'-----&lt;/SPAN&gt;
    prjObject.Close
    &lt;SPAN class="hljs-keyword"&gt;If&lt;/SPAN&gt; Checkerror(&lt;SPAN class="hljs-string"&gt;"Project.Close"&lt;/SPAN&gt;) = &lt;SPAN class="hljs-literal"&gt;True&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;Then&lt;/SPAN&gt;
        &lt;SPAN class="hljs-keyword"&gt;Exit&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;Sub&lt;/SPAN&gt;
    &lt;SPAN class="hljs-keyword"&gt;End&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;If&lt;/SPAN&gt;
       
&lt;SPAN class="hljs-keyword"&gt;End&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;Sub&lt;/SPAN&gt;

&lt;SPAN class="hljs-keyword"&gt;Function&lt;/SPAN&gt; Checkerror(fnName)
    Checkerror = &lt;SPAN class="hljs-literal"&gt;False&lt;/SPAN&gt;
    
    &lt;SPAN class="hljs-keyword"&gt;Dim&lt;/SPAN&gt; strmsg
    &lt;SPAN class="hljs-keyword"&gt;Dim&lt;/SPAN&gt; errNum
    
    &lt;SPAN class="hljs-keyword"&gt;If&lt;/SPAN&gt; Err.Number &amp;lt;&amp;gt; &lt;SPAN class="hljs-number"&gt;0&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;Then&lt;/SPAN&gt;
        strmsg = &lt;SPAN class="hljs-string"&gt;"Error #"&lt;/SPAN&gt; &amp;amp; Hex(Err.Number) &amp;amp; vbCrLf &amp;amp; &lt;SPAN class="hljs-string"&gt;"In Function "&lt;/SPAN&gt; &amp;amp; fnName &amp;amp; vbCrLf &amp;amp; Err.Description
        &lt;SPAN class="hljs-comment"&gt;'MsgBox strmsg  'Uncomment this line if you want to be notified via MessageBox of Errors in the script.&lt;/SPAN&gt;
        Checkerror = &lt;SPAN class="hljs-literal"&gt;True&lt;/SPAN&gt;
    &lt;SPAN class="hljs-keyword"&gt;End&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;If&lt;/SPAN&gt;
         
&lt;SPAN class="hljs-keyword"&gt;End&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;Function&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone tell me how to output the &lt;STRONG&gt;entire&lt;/STRONG&gt; SAS Project Log File to an external .log file? And if possible replacing it, not appending it to the past one.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 15:23:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-the-SAS-Project-Log-File-to-an-external-file/m-p/734269#M228763</guid>
      <dc:creator>KermitTheFrog</dc:creator>
      <dc:date>2021-04-15T15:23:32Z</dc:date>
    </item>
    <item>
      <title>Re: Output the SAS Project Log File to an external file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-the-SAS-Project-Log-File-to-an-external-file/m-p/734398#M228793</link>
      <description>&lt;P&gt;In each sas program you can use the&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1oardywxmmut7n1pol0zkj5u1ok.htm" target="_self"&gt;proc printto&lt;/A&gt;&amp;nbsp;procedure to output to a unique text file log.&lt;/P&gt;&lt;P&gt;Alternately, you can create a new sas program and preface it with a proc printto procedure and have it run all of your unique sas jobs using&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsglobal/p1s3uhhqtscz2sn1otiatbovfn1t.htm" target="_self"&gt;%include&lt;/A&gt;. Like so:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc printto new log="C:\filepath\log.txt";
run;

%include "C:\filepath\job1.sas";
%include "C:\filepath\job2.sas";
/* repeat as necessary */
%include "C:\filepath\jobn.sas";&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;All the logs from the jobs ran using this sas job will be compiled into your c:\filepath\log.txt file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Of course, that's assuming you are able to avoid using vba in running any of your programs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The new option in the proc printto statement will replace instead of append to the file.&lt;/P&gt;&lt;P&gt;If you need a new log every time, you can have sas generate the txt file with a date.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc printto log = "c:\filepath\log_%sysfunc(today,yymmddn6.).txt";
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 18:30:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-the-SAS-Project-Log-File-to-an-external-file/m-p/734398#M228793</guid>
      <dc:creator>JNR</dc:creator>
      <dc:date>2021-04-15T18:30:42Z</dc:date>
    </item>
  </channel>
</rss>

