<?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: Is there a way not only save the log in a text file but also have it output in the SAS log windo in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-not-only-save-the-log-in-a-text-file-but-also/m-p/918132#M361668</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;What is the altlog option? If using the code to put copy back in the end, I won't see anything until completing running a batch. Is there a way to monitor the log at the same time?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;As Tom and Yabwon have showed, you can use PROC PRINTTO to send the log to a file, and then at the end of your code you can read that file to send the text back to your log window.&amp;nbsp; That is how I do stuff like this when I'm using Enterprise Guide.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're using PC SAS (Display manager) in an interactive SAS session, another option is to let your log be written to the default log window, and then you can save the contents of the log file to a text file.&amp;nbsp; And you can do it with code, using a DM statement with the FILE command to write the log window contents to a file:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;dm "log; file ""Q:\junk\__mylog.log"" replace;";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But if you want the log messages to be written to your log window and a file at the same time, I think altlog is your best solution.&amp;nbsp; I've actually never used altlog for that purpose, because I'm happy waiting for the submission to be complete before I can see the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I did submit a SAS ballot question years ago to recommend that SAS make it possible to turn on ALTLOG during a session, using an OPTIONS statement, but that suggestion was never implemented, and was not carried over into the new submission system. So I don't think there's much hope for that.&lt;/P&gt;</description>
    <pubDate>Tue, 27 Feb 2024 21:43:52 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2024-02-27T21:43:52Z</dc:date>
    <item>
      <title>Is there a way not only save the log in a text file but also have it output in the SAS log window?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-not-only-save-the-log-in-a-text-file-but-also/m-p/918046#M361642</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a code to output the log as a text file, but I found out no record was shown in the log window.&amp;nbsp; Is there a way to do both? Thanks.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dira=%str(Pathway);
proc printto log="&amp;amp;dira.test\Citgo_test_&amp;amp;StartTime1..txt" new;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Feb 2024 15:41:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-not-only-save-the-log-in-a-text-file-but-also/m-p/918046#M361642</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2024-02-27T15:41:42Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way not only save the log in a text file but also have it output in the SAS log windo</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-not-only-save-the-log-in-a-text-file-but-also/m-p/918052#M361643</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a code to output the log as a text file, but I found out no record was shown in the log window.&amp;nbsp; Is there a way to do both? Thanks.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dira=%str(Pathway);
proc printto log="&amp;amp;dira.test\Citgo_test_&amp;amp;StartTime1..txt" new;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;LOG "window"?&amp;nbsp; Are you running interactively?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you were running "batch" (that is not interactively but by running SAS from the command line) then you could use the -altlog option to have a separate log file that included everything, including the part redirected by PROC PRINTTO.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise put a copy back into the normal LOG yourself by adding this step afterwards.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;...
proc printto log=log; run;
data _null_;
  infile "&amp;amp;dira.test\Citgo_test_&amp;amp;StartTime1..txt";
  input;
  put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2024 15:53:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-not-only-save-the-log-in-a-text-file-but-also/m-p/918052#M361643</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-02-27T15:53:31Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way not only save the log in a text file but also have it output in the SAS log windo</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-not-only-save-the-log-in-a-text-file-but-also/m-p/918055#M361645</link>
      <description>What is the altlog option?  If using the code to put copy back in the end, I won't see anything until completing running a batch.  Is there a way to monitor the log at the same time?</description>
      <pubDate>Tue, 27 Feb 2024 16:07:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-not-only-save-the-log-in-a-text-file-but-also/m-p/918055#M361645</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2024-02-27T16:07:32Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way not only save the log in a text file but also have it output in the SAS log windo</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-not-only-save-the-log-in-a-text-file-but-also/m-p/918064#M361653</link>
      <description>&lt;P&gt;See docs for altlog:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/hostwin/n02cl0iq0k1fmxn11p83yirplodk.htm#:~:text=The%20ALTLOG%20system%20option%20specifies,name%20for%20the%20destination%20value" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/hostwin/n02cl0iq0k1fmxn11p83yirplodk.htm#:~:text=The%20ALTLOG%20system%20option%20specifies,name%20for%20the%20destination%20value&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically, altlog allows you to write the log to two different locations at the same time, unlike PROC PRINTTO which changes where the log is written.&amp;nbsp; Unfortunately, altlog has to be specified at SAS invocation / in a config file, you can't set it with an option during a session.&amp;nbsp; But it should allow you to see the normal log in your IDE, and have the log written to a file in the background.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2024 16:29:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-not-only-save-the-log-in-a-text-file-but-also/m-p/918064#M361653</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-02-27T16:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way not only save the log in a text file but also have it output in the SAS log windo</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-not-only-save-the-log-in-a-text-file-but-also/m-p/918099#M361656</link>
      <description>&lt;P&gt;How do I use the Altlog option if I want to set a designated pathway?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dira=%str(Pathway);
proc altlog="&amp;amp;dira.\Citgo_GA_&amp;amp;StartTime1..txt".log;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The code didn't work&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2024 18:47:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-not-only-save-the-log-in-a-text-file-but-also/m-p/918099#M361656</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2024-02-27T18:47:04Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way not only save the log in a text file but also have it output in the SAS log windo</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-not-only-save-the-log-in-a-text-file-but-also/m-p/918112#M361664</link>
      <description>&lt;P&gt;It's not a PROC, it's a system option.&amp;nbsp; The system option needs to be set before your SAS session starts.&amp;nbsp; How to set the system option depends on your environment.&amp;nbsp; If your SAS session is running on a server, you would likely need to ask your server admin to change the setting.&amp;nbsp; If your SAS session is running on your PC ("Windows SAS"), then you should be able to set it yourself, in the config file or in the command that starts your SAS session.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2024 19:53:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-not-only-save-the-log-in-a-text-file-but-also/m-p/918112#M361664</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-02-27T19:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way not only save the log in a text file but also have it output in the SAS log windo</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-not-only-save-the-log-in-a-text-file-but-also/m-p/918113#M361665</link>
      <description>&lt;P&gt;As you mentioned (and as described in the documentation), ALTLOG is an&amp;nbsp;&lt;U&gt;option&lt;/U&gt;, not a&amp;nbsp;&lt;U&gt;procedure&lt;/U&gt;. As you can also see in the documentation, it has to be set at SAS invocation, either from the commandline or in the configuration file(s). You cannot set it from code. If you want to have a log file of all actions done in a workspace server session (which is the backend for Enterprise Guide and SAS Studio), while also keeping your client-side log, you have to configure server-side logging accordingly. This is done in the logconfig.xml file in the configuration tree of your SAS server.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2024 19:57:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-not-only-save-the-log-in-a-text-file-but-also/m-p/918113#M361665</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-02-27T19:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way not only save the log in a text file but also have it output in the SAS log windo</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-not-only-save-the-log-in-a-text-file-but-also/m-p/918122#M361666</link>
      <description>&lt;P&gt;Define two macros (store them in autoexec, or somewhere else):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro Before(path,fileref=L);
filename &amp;amp;fileref. "&amp;amp;path.";
proc printto log = &amp;amp;fileref. NEW;
run;
%mend Before;


%macro After(fileref=L);
proc printto;
run;
filename &amp;amp;fileref. list;
data _null_;
  infile &amp;amp;fileref.;
  input;
  putlog _infile_; 
run;
filename &amp;amp;fileref. clear;
%mend After;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And the run for example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%Before(R:\file_for_log.txt)

/* your code goes here, e.g. */
data new_darta;
  set sashelp.class;
  age_plus_2 = AGE + 2;
run;


%After()&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You will get the following log and the file "&lt;CODE class=" language-sas"&gt;R:\file_for_log.txt&lt;/CODE&gt;" too:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1    %Before(R:\file_for_log.txt)

NOTE: PROCEDURE PRINTTO used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


NOTE: Fileref= L
      Physical Name= R:\file_for_log.txt

NOTE: The infile L is:
      Filename=R:\file_for_log.txt,
      RECFM=V,LRECL=32767,File Size (bytes)=593,
      Last Modified=27Feb2024:21:29:13,
      Create Time=27Feb2024:21:26:12

NOTE: PROCEDURE PRINTTO used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


2
3    /* your code goes here, e.g. */
4    data new_darta;
5      set sashelp.class;
6      age_plus_2 = AGE + 2;
7    run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.NEW_DARTA has 19 observations and 6 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


8
9
10   %After()
NOTE: 23 records were read from the infile L.
      The minimum record length was 0.
      The maximum record length was 70.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds


NOTE: Fileref L has been deassigned.
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2024 20:30:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-not-only-save-the-log-in-a-text-file-but-also/m-p/918122#M361666</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-02-27T20:30:18Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way not only save the log in a text file but also have it output in the SAS log windo</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-not-only-save-the-log-in-a-text-file-but-also/m-p/918132#M361668</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;What is the altlog option? If using the code to put copy back in the end, I won't see anything until completing running a batch. Is there a way to monitor the log at the same time?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;As Tom and Yabwon have showed, you can use PROC PRINTTO to send the log to a file, and then at the end of your code you can read that file to send the text back to your log window.&amp;nbsp; That is how I do stuff like this when I'm using Enterprise Guide.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're using PC SAS (Display manager) in an interactive SAS session, another option is to let your log be written to the default log window, and then you can save the contents of the log file to a text file.&amp;nbsp; And you can do it with code, using a DM statement with the FILE command to write the log window contents to a file:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;dm "log; file ""Q:\junk\__mylog.log"" replace;";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But if you want the log messages to be written to your log window and a file at the same time, I think altlog is your best solution.&amp;nbsp; I've actually never used altlog for that purpose, because I'm happy waiting for the submission to be complete before I can see the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I did submit a SAS ballot question years ago to recommend that SAS make it possible to turn on ALTLOG during a session, using an OPTIONS statement, but that suggestion was never implemented, and was not carried over into the new submission system. So I don't think there's much hope for that.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2024 21:43:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-not-only-save-the-log-in-a-text-file-but-also/m-p/918132#M361668</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-02-27T21:43:52Z</dc:date>
    </item>
  </channel>
</rss>

