<?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: write inside main log program and include program in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/write-inside-main-log-program-and-include-program/m-p/853011#M337181</link>
    <description>&lt;P&gt;hello&lt;/P&gt;
&lt;P&gt;thanks for your answer;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;No, the request was not to just write only start/stop messages to a different file. but&amp;nbsp; this was not specifed in my post. your proposal works well&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;thanks&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Nasser&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 10 Jan 2023 08:08:08 GMT</pubDate>
    <dc:creator>Nasser_DRMCP</dc:creator>
    <dc:date>2023-01-10T08:08:08Z</dc:date>
    <item>
      <title>write inside main log program and include program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/write-inside-main-log-program-and-include-program/m-p/852526#M336991</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;my problem is that the content of the main plog is&lt;/P&gt;
&lt;P&gt;"this is the begin of the main prog"&lt;/P&gt;
&lt;P&gt;%include "$GRPSBSAS/RQTCP_EI/DEV/include.sas" ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and that s all. I wonder why the main prog does not continue to write "this is the end of the main prog".&lt;/P&gt;
&lt;P&gt;I would like to be able to open then to write in a main log.&lt;/P&gt;
&lt;P&gt;Then creating and writing in a sub log.&lt;/P&gt;
&lt;P&gt;And then, opening again and write again in the main log.&lt;/P&gt;
&lt;P&gt;But it seems to me that the proc printto of the include prog also close the main log&lt;/P&gt;
&lt;P&gt;Thanks for your help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;/* below main prog*/
PROC PRINTTO LOG="main.log" NEW; 
RUN;

%put this is the begin of the main prog ;
%include "$GRPSBSAS/RQTCP_EI/DEV/include.sas" ;
%put this is the end of the main prog ;

PROC PRINTTO;
RUN;

/* below an include sub programme*/
PROC PRINTTO LOG="include.log" NEW; 
RUN;

%put this is the begin of the include prog ;
%put this is the end of the include prog ;

PROC PRINTTO;
RUN;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Jan 2023 16:12:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/write-inside-main-log-program-and-include-program/m-p/852526#M336991</guid>
      <dc:creator>Nasser_DRMCP</dc:creator>
      <dc:date>2023-01-06T16:12:27Z</dc:date>
    </item>
    <item>
      <title>Re: write inside main log program and include program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/write-inside-main-log-program-and-include-program/m-p/852528#M336993</link>
      <description>&lt;P&gt;I'm not 100% sure I understand. The part that confuses me is that you have PROC PRINTTO below the main program, I think you would want it above the main program. Similarly, you have PROC PRINTTO LOG="include.log" after the %include, I would think you want it before the %include.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think this would work as you have written it ... but maybe you want the PROC PRINTTO above rather than below as you have written it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* below main prog*/
PROC PRINTTO LOG="main.log" NEW; 
RUN;

%put this is the begin of the main prog ;
%include "$GRPSBSAS/RQTCP_EI/DEV/include.sas" ;
%put this is the end of the main prog ;

/* below an include sub programme*/
PROC PRINTTO LOG="include.log" NEW; 
RUN;

%put this is the begin of the include prog ;
%put this is the end of the include prog ;

PROC PRINTTO LOG="main.log" ;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So the log of your %include gets written to main.log. Then the next items get written to include.log, and anything after that gets written to main.log. But maybe, as I said, you want PROC PRINTTO before rather than after.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 16:24:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/write-inside-main-log-program-and-include-program/m-p/852528#M336993</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-01-06T16:24:18Z</dc:date>
    </item>
    <item>
      <title>Re: write inside main log program and include program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/write-inside-main-log-program-and-include-program/m-p/852706#M337051</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/147725"&gt;@Nasser_DRMCP&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"it seems to me that the proc printto of the include prog also close the main log".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's what happens, but your description of this behaviour is incorrect, because the included program doesn't have it's own log.&amp;nbsp;Included code is not executed in a side session, it is just copied to the program stack and executed in the main session. The main session has a log that can be redirected to another destination vist Proc Printto log=xxx; statement, until it is "taken back" to the default destination with a Proc Printto; statement. One can't have two log destinations open at the same time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Therefore, you cannnot write to the main log while the log is redirected. It makes no difference if the log is redirected in the main program or in the included code.&amp;nbsp;I wonder what happens with log redirecting if the included code is executed by the Dosubl function and actually runs in a side session. I will try that out later.&lt;/P&gt;</description>
      <pubDate>Sun, 08 Jan 2023 18:52:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/write-inside-main-log-program-and-include-program/m-p/852706#M337051</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2023-01-08T18:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: write inside main log program and include program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/write-inside-main-log-program-and-include-program/m-p/852740#M337060</link>
      <description>&lt;P&gt;Many Thanks Paige and Erik. Sorry if my description was not so clear !&lt;/P&gt;
&lt;P&gt;Thanks to yours answers I get the attended result.&lt;/P&gt;
&lt;P&gt;as you can see in the new inserted code, I use this :&lt;/P&gt;
&lt;P&gt;PROC PRINTTO LOG="main.log" ; RUN; (without "NEW") to write again in the main.log file&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The main log contains this text below as I wanted (I added a third included program)&lt;/P&gt;
&lt;P&gt;prog include is lauched&lt;/P&gt;
&lt;P&gt;prog include is complete&lt;/P&gt;
&lt;P&gt;prog include2 is lauched&lt;/P&gt;
&lt;P&gt;prog include2 is complete&lt;/P&gt;
&lt;P&gt;prog include3 is lauched&lt;/P&gt;
&lt;P&gt;prog include3 is complete&lt;/P&gt;
&lt;PRE&gt;PROC PRINTTO LOG="main.log" NEW; RUN;

%put this is the begin of the main prog ;

%put prog include is lauched ;
%include "$GRPSBSAS/RQTCP_EI/DEV/include.sas" ;
PROC PRINTTO LOG="main.log" ; RUN;
%put prog include is completed ;

%put prog include2 is lauched ;
%include "$GRPSBSAS/RQTCP_EI/DEV/include2.sas" ;
PROC PRINTTO LOG="main.log" ; RUN;
%put prog include2 is completed ;

%put prog include3 is lauched ;
%include "$GRPSBSAS/RQTCP_EI/DEV/include3.sas" ;
PROC PRINTTO LOG="main.log" ; RUN;
%put prog include3 is completed ;

%put this is the end of the main prog ;

PROC PRINTTO;
RUN;&lt;/PRE&gt;
&lt;P&gt;Then include.log (or 2 or 3) file contains&lt;/P&gt;
&lt;P&gt;"this is the begin of the include prog (or 2 or 3)&lt;BR /&gt;this is the end of the include prog(or 2 or 3)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2023 08:54:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/write-inside-main-log-program-and-include-program/m-p/852740#M337060</guid>
      <dc:creator>Nasser_DRMCP</dc:creator>
      <dc:date>2023-01-09T08:54:05Z</dc:date>
    </item>
    <item>
      <title>Re: write inside main log program and include program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/write-inside-main-log-program-and-include-program/m-p/852915#M337131</link>
      <description>&lt;P&gt;So from the solution you posted it looks like the actual problem is that the "subroutines" (the included files) are also using PROC PRINTTO?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or was the request to just write only those start/stop messages to a different file?&lt;/P&gt;
&lt;P&gt;If so then why not just do that instead of using PROC PRINTTO so that the actual log messages stay in the actual log?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  file "main.log" ;
  put 'this is the begin of the main prog';
run;

data _null_;
  file "main.log" mod;
  put 'prog include is launched';
run;
%include "$GRPSBSAS/RQTCP_EI/DEV/include.sas" ;
data _null_;
  file "main.log" mod;
  put 'prog include is completed ';
run;
...
data _null_;
  file "main.log" mod;
  put 'this is the end of the main prog';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Jan 2023 20:05:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/write-inside-main-log-program-and-include-program/m-p/852915#M337131</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-01-09T20:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: write inside main log program and include program</title>
      <link>https://communities.sas.com/t5/SAS-Programming/write-inside-main-log-program-and-include-program/m-p/853011#M337181</link>
      <description>&lt;P&gt;hello&lt;/P&gt;
&lt;P&gt;thanks for your answer;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;No, the request was not to just write only start/stop messages to a different file. but&amp;nbsp; this was not specifed in my post. your proposal works well&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;thanks&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Nasser&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2023 08:08:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/write-inside-main-log-program-and-include-program/m-p/853011#M337181</guid>
      <dc:creator>Nasser_DRMCP</dc:creator>
      <dc:date>2023-01-10T08:08:08Z</dc:date>
    </item>
  </channel>
</rss>

