<?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 Log redirect inside log redirect, return to original log in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Log-redirect-inside-log-redirect-return-to-original-log/m-p/646619#M193466</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Problem:&lt;/P&gt;&lt;P&gt;We are changing from using the tcp_tso script to gain access to the Mainframe, to using SAS Spawners on the Mainframe. Using option NLSCOMPATMODE when logging onto SAS on the Mainframe presents a WARNING: message. This message will break jobs run via LSF as the rc is 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Potential solution:&lt;BR /&gt;A centralised macro is being written to provide all SAS users with a common logon method. To hide the WARNING: message, the macro redirects the log file temporarily while the logon to the Mainframe takes place. The log is then closed, ingested into a dataset and any ERROR: or WARNING: message is reported to the user.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Problem with solution:&lt;/P&gt;&lt;P&gt;The user may have already redirected their log with proc printto. When my macro stops redirecting the log for its own purpose, the log then returns to (in EGuide) the interactive log window, rather than the users redirected log.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc printto log="/user/redirected/log.log" new; run;
/* This writes to the users redirected log correctly */&lt;BR /&gt;%put I am writing to the log.;
&lt;BR /&gt;/* When my macro runs, it redirects the log once more, and upon signon completion, closes that log */
%MyMacro;

/* This returns to the EGuide log rather than "/user/redirected/log.log"&amp;nbsp;*/
%put I am writing to the log again.;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the redirect start and end code from my macro:&lt;/P&gt;&lt;PRE&gt;%let workdir=%qsysfunc(dequote(&amp;amp;SASWORKLOCATION));
filename lf "&amp;amp;workdir.mf_connect.log";
proc printto log=lf new; run;

/*...lots of code here...*/

/*	Release the log so we can ingest it.	*/
proc printto log=log; run;&lt;/PRE&gt;&lt;P&gt;Am I doing something wrong with the way I end my redirection - such as missing an option that would not force the log back to the 'default' and instead return to the user redirected log?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 11 May 2020 10:46:07 GMT</pubDate>
    <dc:creator>_Dan_</dc:creator>
    <dc:date>2020-05-11T10:46:07Z</dc:date>
    <item>
      <title>Log redirect inside log redirect, return to original log</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Log-redirect-inside-log-redirect-return-to-original-log/m-p/646619#M193466</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Problem:&lt;/P&gt;&lt;P&gt;We are changing from using the tcp_tso script to gain access to the Mainframe, to using SAS Spawners on the Mainframe. Using option NLSCOMPATMODE when logging onto SAS on the Mainframe presents a WARNING: message. This message will break jobs run via LSF as the rc is 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Potential solution:&lt;BR /&gt;A centralised macro is being written to provide all SAS users with a common logon method. To hide the WARNING: message, the macro redirects the log file temporarily while the logon to the Mainframe takes place. The log is then closed, ingested into a dataset and any ERROR: or WARNING: message is reported to the user.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Problem with solution:&lt;/P&gt;&lt;P&gt;The user may have already redirected their log with proc printto. When my macro stops redirecting the log for its own purpose, the log then returns to (in EGuide) the interactive log window, rather than the users redirected log.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc printto log="/user/redirected/log.log" new; run;
/* This writes to the users redirected log correctly */&lt;BR /&gt;%put I am writing to the log.;
&lt;BR /&gt;/* When my macro runs, it redirects the log once more, and upon signon completion, closes that log */
%MyMacro;

/* This returns to the EGuide log rather than "/user/redirected/log.log"&amp;nbsp;*/
%put I am writing to the log again.;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the redirect start and end code from my macro:&lt;/P&gt;&lt;PRE&gt;%let workdir=%qsysfunc(dequote(&amp;amp;SASWORKLOCATION));
filename lf "&amp;amp;workdir.mf_connect.log";
proc printto log=lf new; run;

/*...lots of code here...*/

/*	Release the log so we can ingest it.	*/
proc printto log=log; run;&lt;/PRE&gt;&lt;P&gt;Am I doing something wrong with the way I end my redirection - such as missing an option that would not force the log back to the 'default' and instead return to the user redirected log?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 May 2020 10:46:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Log-redirect-inside-log-redirect-return-to-original-log/m-p/646619#M193466</guid>
      <dc:creator>_Dan_</dc:creator>
      <dc:date>2020-05-11T10:46:07Z</dc:date>
    </item>
    <item>
      <title>Re: Log redirect inside log redirect, return to original log</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Log-redirect-inside-log-redirect-return-to-original-log/m-p/646626#M193469</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How about first checking if the log is already redirected?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%local localLog;
%let localLog = %superq(SYSPRINTTOLOG); 

%let workdir=%qsysfunc(dequote(&amp;amp;SASWORKLOCATION));
filename lf "&amp;amp;workdir.mf_connect.log";
proc printto log=lf new; run;

/*...lots of code here...*/

/*	Release the log so we can ingest it.	*/
%if %bquote(&amp;amp;localLog.)= %then %do;
proc printto log=log; run;
%end;
%else %do;
proc printto log=&amp;amp;localLog.; run;
%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All the best&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 11 May 2020 11:00:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Log-redirect-inside-log-redirect-return-to-original-log/m-p/646626#M193469</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-05-11T11:00:30Z</dc:date>
    </item>
    <item>
      <title>Re: Log redirect inside log redirect, return to original log</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Log-redirect-inside-log-redirect-return-to-original-log/m-p/646662#M193483</link>
      <description>That had crossed my mind and I was probably one Google search away from looking for %superq(SYSPRINTTOLOG).&lt;BR /&gt;&lt;BR /&gt;Thanks for the tip, I'll give it a try.</description>
      <pubDate>Mon, 11 May 2020 12:21:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Log-redirect-inside-log-redirect-return-to-original-log/m-p/646662#M193483</guid>
      <dc:creator>_Dan_</dc:creator>
      <dc:date>2020-05-11T12:21:18Z</dc:date>
    </item>
  </channel>
</rss>

