<?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: Clear log every N interation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Clear-log-every-N-interation/m-p/799135#M314206</link>
    <description>&lt;P&gt;I'm generally opposed to the idea of turning off writing to the log or automatically clearing a log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;People who do that often think "I know this code works now, so I don't need the log."&amp;nbsp; I think that is a dangerous thought.&amp;nbsp; Much safer to write the log to a file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That said, can you tell us which IDE you are using?&amp;nbsp; If you are using Display Manager (PC SAS) I believe you can clear the log by submitting&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;dm 'log;clear;';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And since you are using CALL EXECUTE to generate your macro calls, you could also use CALL EXECUTE to execute the DM command after N loops of the data step, e.g. :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_ ;
  do i=1 to 10 ;
    put i= ;

    call execute('data foo ; x=' || i ||' ;run ;') ;

    if mod(i,4)=0 then do ;
      call execute("dm 'log ;clear ;';") ;
    end ;
  end ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I doubt there is a similar way to dynamically clear the log while a DATA step is executing in Studio or EG, because they are essentially batch submissions rather than interactive (as I understand it).&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And generally, I would think clearing the log in the middle of a DATA step is a #VeryBadIdea.&amp;nbsp; You never know what can go wrong (in a program you wrote, the data being read, or the computer it's running on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Feb 2022 14:56:18 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2022-02-28T14:56:18Z</dc:date>
    <item>
      <title>Clear log every N interation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Clear-log-every-N-interation/m-p/799038#M314149</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have a macro and I run this marcro for every row in VAR_LIST dataset.&lt;/P&gt;
&lt;P&gt;The thing is, there are thousands of row in Var_list and the log will get full quickly during the EXECUTE step in my code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there any way we can put a counting variables and request SAS to clear log every, say 1000 execution.&lt;/P&gt;
&lt;P&gt;I don't want to save log in a separated txt file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please help?&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*GET VAR_LIST;&lt;BR /&gt;ods select none;
proc contents data=have out=var_list (keep = name);
run;
ods select all;
&lt;BR /&gt;*EXECUTE------------------------- Can we clear log every 1000 execution?;
data execute_all;
set var_list;
where name ne 'n';

str = catt('%lastdate(column=', name, ');');
call execute(str);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Feb 2022 00:46:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Clear-log-every-N-interation/m-p/799038#M314149</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2022-02-28T00:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: Clear log every N interation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Clear-log-every-N-interation/m-p/799040#M314150</link>
      <description>How about using "options nonotes" to prevent to print notes?</description>
      <pubDate>Mon, 28 Feb 2022 01:11:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Clear-log-every-N-interation/m-p/799040#M314150</guid>
      <dc:creator>whymath</dc:creator>
      <dc:date>2022-02-28T01:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: Clear log every N interation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Clear-log-every-N-interation/m-p/799041#M314151</link>
      <description>&lt;P&gt;Oh, I still want to see the log once in a while.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Feb 2022 01:15:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Clear-log-every-N-interation/m-p/799041#M314151</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2022-02-28T01:15:44Z</dc:date>
    </item>
    <item>
      <title>Re: Clear log every N interation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Clear-log-every-N-interation/m-p/799042#M314152</link>
      <description>&lt;P&gt;If you run your program in batch mode your SAS log never becomes "full" unless you run out of disk space.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Feb 2022 01:27:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Clear-log-every-N-interation/m-p/799042#M314152</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-02-28T01:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: Clear log every N interation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Clear-log-every-N-interation/m-p/799048#M314155</link>
      <description>&lt;P&gt;You may want to know the "dmslogsize=" system option(&lt;A href="https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#base-sysop-dmslogsize.htm" target="_self"&gt;link&lt;/A&gt;). You can set it to 999999 and this is the maximum value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Feb 2022 02:15:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Clear-log-every-N-interation/m-p/799048#M314155</guid>
      <dc:creator>whymath</dc:creator>
      <dc:date>2022-02-28T02:15:46Z</dc:date>
    </item>
    <item>
      <title>Re: Clear log every N interation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Clear-log-every-N-interation/m-p/799049#M314156</link>
      <description>&lt;P&gt;Why don't you want the log in a separate file?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you done normal steps to prevent the log from being filled with unneeded lines?&lt;BR /&gt;Turn off FULLSTIMER option.&lt;/P&gt;
&lt;P&gt;Turn off MLOGIC and SYMBOLGEN option.&lt;/P&gt;
&lt;P&gt;If your macro is stable then turn off MPRINT option also.&lt;/P&gt;
&lt;P&gt;Prevent CALL EXECUTE() from pushing the code the macro generates into the stack to run by using %NRSTR() in your string.&lt;/P&gt;
&lt;P&gt;Also don't append that extra ';' after the macro call.&amp;nbsp; You don't need it since obviously the macro is generating multiple statements already or you wouldn't be worried about the size of the log.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call execute(cats('%nrstr(%lastdate)(column=', name, ')'));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And of course the most obvious thing, change your process to do the whole dataset at once instead of variable by variable.&lt;/P&gt;
&lt;P&gt;What does %LASTDATE() do?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Feb 2022 02:32:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Clear-log-every-N-interation/m-p/799049#M314156</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-02-28T02:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: Clear log every N interation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Clear-log-every-N-interation/m-p/799135#M314206</link>
      <description>&lt;P&gt;I'm generally opposed to the idea of turning off writing to the log or automatically clearing a log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;People who do that often think "I know this code works now, so I don't need the log."&amp;nbsp; I think that is a dangerous thought.&amp;nbsp; Much safer to write the log to a file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That said, can you tell us which IDE you are using?&amp;nbsp; If you are using Display Manager (PC SAS) I believe you can clear the log by submitting&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;dm 'log;clear;';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And since you are using CALL EXECUTE to generate your macro calls, you could also use CALL EXECUTE to execute the DM command after N loops of the data step, e.g. :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_ ;
  do i=1 to 10 ;
    put i= ;

    call execute('data foo ; x=' || i ||' ;run ;') ;

    if mod(i,4)=0 then do ;
      call execute("dm 'log ;clear ;';") ;
    end ;
  end ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I doubt there is a similar way to dynamically clear the log while a DATA step is executing in Studio or EG, because they are essentially batch submissions rather than interactive (as I understand it).&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And generally, I would think clearing the log in the middle of a DATA step is a #VeryBadIdea.&amp;nbsp; You never know what can go wrong (in a program you wrote, the data being read, or the computer it's running on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Feb 2022 14:56:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Clear-log-every-N-interation/m-p/799135#M314206</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-02-28T14:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: Clear log every N interation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Clear-log-every-N-interation/m-p/799145#M314208</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm generally opposed to the idea of turning off writing to the log or automatically clearing a log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, I agree completely, Quentin.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;And generally, I would think clearing the log in the middle of a DATA step is a #VeryBadIdea.&amp;nbsp; You never know what can go wrong (in a program you wrote, the data being read, or the computer it's running on.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, I agree completely, Quentin.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if your program is likely to create a very very very very big log, write the log to a file instead of to the LOG window.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have set up, in Base SAS Display Manager a keystroke combination that clears the log whenever I want (but it doesn't work while the program is running). So its a manual thing. I also choose the submit command as part of this keystroke combination, so it clears the previous log and a new log is created. Of course I only do this after checking the log from my previous run, and have fixed (I hope) the errors, and am ready to run it again and I don't need the old log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you type Keys into the command bar at the top left, a window appears that lets you assign specific commands to specific keystrokes. Next the SHF F1 (Shift-F1), I have entered&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;cle log; submit&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and so now when I press Shift-F1, my previous log is cleared and the code in the Enhanced editor window (or the selected code in the Enhanced Editor window) starts running. Slick trick.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Feb 2022 15:52:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Clear-log-every-N-interation/m-p/799145#M314208</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-02-28T15:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: Clear log every N interation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Clear-log-every-N-interation/m-p/799172#M314221</link>
      <description>&lt;P&gt;I am really appreciate your help and insight.&lt;/P&gt;
&lt;P&gt;They are very helpful!&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;</description>
      <pubDate>Mon, 28 Feb 2022 16:39:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Clear-log-every-N-interation/m-p/799172#M314221</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2022-02-28T16:39:22Z</dc:date>
    </item>
  </channel>
</rss>

