<?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: DO LOOP FOR X TIME EVERY MINUTE FOR 5 MIN in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/DO-LOOP-FOR-X-TIME-EVERY-MINUTE-FOR-5-MIN/m-p/561417#M157161</link>
    <description>&lt;P&gt;The default time unit for the SLEEP function is different between windows and LinuxUnix.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Under windows the default time unit is 1 SECOND. Under Linux the default time unit is 1 MILLISECOND.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To avoid this issue, specify the time unit in the call to SLEEP:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;e.g.;&lt;/P&gt;&lt;P&gt;SLEEP(100,1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;tells SAS to sleep for 100 seconds on both Windows and Linux/Unix.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 24 May 2019 14:43:28 GMT</pubDate>
    <dc:creator>DWilson</dc:creator>
    <dc:date>2019-05-24T14:43:28Z</dc:date>
    <item>
      <title>DO LOOP FOR X TIME EVERY MINUTE FOR 5 MIN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-LOOP-FOR-X-TIME-EVERY-MINUTE-FOR-5-MIN/m-p/561382#M157145</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have below simple code but want to trick it to &lt;STRONG&gt;run it once every minute&lt;/STRONG&gt; + &lt;STRONG&gt;count run&lt;/STRONG&gt; + &lt;STRONG&gt;max run is 5&lt;/STRONG&gt; + &lt;STRONG&gt;and put message (max run reached) in log once max run (i.e. 5) reached&lt;/STRONG&gt;&amp;nbsp;how i do it? i tried different way but error is "statement is out of proper order"&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do %until (condition);
data _null_;
rc=SLEEP(60*1);
run;
%END;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 May 2019 13:33:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-LOOP-FOR-X-TIME-EVERY-MINUTE-FOR-5-MIN/m-p/561382#M157145</guid>
      <dc:creator>elisas</dc:creator>
      <dc:date>2019-05-24T13:33:42Z</dc:date>
    </item>
    <item>
      <title>Re: DO LOOP FOR X TIME EVERY MINUTE FOR 5 MIN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-LOOP-FOR-X-TIME-EVERY-MINUTE-FOR-5-MIN/m-p/561385#M157147</link>
      <description>&lt;P&gt;Please provide more context and more explanation and more detail of this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;run it once every minute&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;+&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;count run&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;+&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;max run is 5&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;+&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;and put message (max run reached) in log once max run (i.e. 5) reached&lt;/STRONG&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Also, if you want it to run 5 times, why not just use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;rc=SLEEP(60*5);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 May 2019 13:52:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-LOOP-FOR-X-TIME-EVERY-MINUTE-FOR-5-MIN/m-p/561385#M157147</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-05-24T13:52:04Z</dc:date>
    </item>
    <item>
      <title>Re: DO LOOP FOR X TIME EVERY MINUTE FOR 5 MIN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-LOOP-FOR-X-TIME-EVERY-MINUTE-FOR-5-MIN/m-p/561388#M157148</link>
      <description>&lt;P&gt;That's a lot of wasted time and resources that could be handled in a better manner.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what you going to do if the file had errors and the other user reran the process?&amp;nbsp; are you checking the modified dates, accessed dates, created dates?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might want to take this one back to the drawing board.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 May 2019 13:44:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-LOOP-FOR-X-TIME-EVERY-MINUTE-FOR-5-MIN/m-p/561388#M157148</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-05-24T13:44:43Z</dc:date>
    </item>
    <item>
      <title>Re: DO LOOP FOR X TIME EVERY MINUTE FOR 5 MIN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-LOOP-FOR-X-TIME-EVERY-MINUTE-FOR-5-MIN/m-p/561390#M157149</link>
      <description>&lt;P&gt;For starters:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;You are using macro programming statements.&amp;nbsp; Did you actually define a macro?&lt;/LI&gt;
&lt;LI&gt;What is the condition in parentheses?&lt;/LI&gt;
&lt;LI&gt;Where is any logic to count the number of iterations?&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Fri, 24 May 2019 13:47:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-LOOP-FOR-X-TIME-EVERY-MINUTE-FOR-5-MIN/m-p/561390#M157149</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-05-24T13:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: DO LOOP FOR X TIME EVERY MINUTE FOR 5 MIN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-LOOP-FOR-X-TIME-EVERY-MINUTE-FOR-5-MIN/m-p/561391#M157150</link>
      <description>&lt;P&gt;actually, this link is awesome solution but (example) i want to run condition only 3 times in 15 minutes (each execution happens 5 min apart) and then stop. once 3 execution completes, put message in log "reached max execution".&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/SAS-MACRO-WITH-SLEEP-FUNCTION/td-p/314327" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/SAS-MACRO-WITH-SLEEP-FUNCTION/td-p/314327&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 May 2019 13:50:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-LOOP-FOR-X-TIME-EVERY-MINUTE-FOR-5-MIN/m-p/561391#M157150</guid>
      <dc:creator>elisas</dc:creator>
      <dc:date>2019-05-24T13:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: DO LOOP FOR X TIME EVERY MINUTE FOR 5 MIN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-LOOP-FOR-X-TIME-EVERY-MINUTE-FOR-5-MIN/m-p/561393#M157151</link>
      <description>&lt;P&gt;sleep should be used in a better manner than how your request is proposing to use it.&amp;nbsp; As a mannager I would want to know what you are doing while the process sleeps.&amp;nbsp; Are you working on another task or just waiting for that process to complete before moving on in your duties.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 May 2019 13:54:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-LOOP-FOR-X-TIME-EVERY-MINUTE-FOR-5-MIN/m-p/561393#M157151</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-05-24T13:54:13Z</dc:date>
    </item>
    <item>
      <title>Re: DO LOOP FOR X TIME EVERY MINUTE FOR 5 MIN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-LOOP-FOR-X-TIME-EVERY-MINUTE-FOR-5-MIN/m-p/561397#M157152</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/275401"&gt;@elisas&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Often when people are trying to set up such a repeated loop, they want to implement some process which waits until a certain condition becomes true (like: a file exists for further processing).&lt;/P&gt;
&lt;P&gt;Why don't you explain us what you're actually trying to achieve (big picture) so we can propose an appropriate solution.&lt;/P&gt;</description>
      <pubDate>Fri, 24 May 2019 14:02:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-LOOP-FOR-X-TIME-EVERY-MINUTE-FOR-5-MIN/m-p/561397#M157152</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-05-24T14:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: DO LOOP FOR X TIME EVERY MINUTE FOR 5 MIN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-LOOP-FOR-X-TIME-EVERY-MINUTE-FOR-5-MIN/m-p/561401#M157153</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/275401"&gt;@elisas&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;actually, this link is awesome solution but (example) i want to run condition only 3 times in 15 minutes (each execution happens 5 min apart) and then stop. once 3 execution completes, put message in log "reached max execution".&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/SAS-MACRO-WITH-SLEEP-FUNCTION/td-p/314327" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/SAS-MACRO-WITH-SLEEP-FUNCTION/td-p/314327&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Thanks, this helps to understand what and why&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO FINDIT;  
    %let count=0;
    %let condition=0;
	%DO %UNTIL(&amp;amp;condition or &amp;amp;count=3);
               %let condition=%SYSFUNC(FILEEXIST(&amp;amp;TESTFILE));
                %let count=%eval(&amp;amp;count+1);
         %if not &amp;amp;condition %then %do;
		data _null_;
		rc=SLEEP(300);
		run;
          %end;	         
            %if &amp;amp;condition %then %do;
	    PROC SQL;
 	    CREATE TABLE WORK.TESTE AS 
	    SELECT *
	    FROM WORK.TB_SAIDA_GPC;
	    QUIT;
        %end;	
	%END;
        %if &amp;amp;count=3 and not &amp;amp;condition %then %put MAX 3 attempts, file not found;
%MEND;                                         
    
%FINDIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Sorry for the poor formatting of the code, I'm lazy today.&lt;/P&gt;</description>
      <pubDate>Fri, 24 May 2019 14:30:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-LOOP-FOR-X-TIME-EVERY-MINUTE-FOR-5-MIN/m-p/561401#M157153</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-05-24T14:30:49Z</dc:date>
    </item>
    <item>
      <title>Re: DO LOOP FOR X TIME EVERY MINUTE FOR 5 MIN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-LOOP-FOR-X-TIME-EVERY-MINUTE-FOR-5-MIN/m-p/561417#M157161</link>
      <description>&lt;P&gt;The default time unit for the SLEEP function is different between windows and LinuxUnix.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Under windows the default time unit is 1 SECOND. Under Linux the default time unit is 1 MILLISECOND.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To avoid this issue, specify the time unit in the call to SLEEP:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;e.g.;&lt;/P&gt;&lt;P&gt;SLEEP(100,1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;tells SAS to sleep for 100 seconds on both Windows and Linux/Unix.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 May 2019 14:43:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-LOOP-FOR-X-TIME-EVERY-MINUTE-FOR-5-MIN/m-p/561417#M157161</guid>
      <dc:creator>DWilson</dc:creator>
      <dc:date>2019-05-24T14:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: DO LOOP FOR X TIME EVERY MINUTE FOR 5 MIN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-LOOP-FOR-X-TIME-EVERY-MINUTE-FOR-5-MIN/m-p/561471#M157187</link>
      <description>&lt;P&gt;Thanks a lot Miller. I tested it two ways, positive/negative scenario and it worked fine.&lt;/P&gt;&lt;P&gt;Don't worry about formatting, you knows SAS EG has cool formatting option, right click in program editor and select "format code"&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;@ Wilson, if i keep sleep (300), it seems working fine, i am running in linux.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 May 2019 16:36:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-LOOP-FOR-X-TIME-EVERY-MINUTE-FOR-5-MIN/m-p/561471#M157187</guid>
      <dc:creator>elisas</dc:creator>
      <dc:date>2019-05-24T16:36:45Z</dc:date>
    </item>
    <item>
      <title>Re: DO LOOP FOR X TIME EVERY MINUTE FOR 5 MIN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/DO-LOOP-FOR-X-TIME-EVERY-MINUTE-FOR-5-MIN/m-p/561579#M157247</link>
      <description>&lt;P&gt;sorry but quick follow up question, if my "condition" is date (if today's date=date from table), how can i interpret, "condition" lines in your code (i tried to put quotation mark around but didn't work). Receiving error like "ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:&lt;BR /&gt;not &amp;amp;condition "?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;    &lt;SPAN class="token macroname"&gt;%let&lt;/SPAN&gt; condition&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;0&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
	&lt;SPAN class="token macrostatement"&gt;%DO&lt;/SPAN&gt; &lt;SPAN class="token macrostatement"&gt;%UNTIL&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;condition or &lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;count&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;3&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
               &lt;SPAN class="token macroname"&gt;%let&lt;/SPAN&gt; condition&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token macrostatement"&gt;%SYSFUNC&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;FILEEXIST&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;TESTFILE&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
               
         &lt;SPAN class="token macrostatement"&gt;%if&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;not&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;condition &lt;SPAN class="token macrostatement"&gt;%then&lt;/SPAN&gt; &lt;SPAN class="token macrostatement"&gt;%do&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
		         
            &lt;SPAN class="token macrostatement"&gt;%if&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;condition &lt;SPAN class="token macrostatement"&gt;%then&lt;/SPAN&gt; &lt;SPAN class="token macrostatement"&gt;%do&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
	   
        &lt;SPAN class="token macrostatement"&gt;%if&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;count&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;3&lt;/SPAN&gt; and &lt;SPAN class="token operator"&gt;not&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;condition&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 May 2019 17:32:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/DO-LOOP-FOR-X-TIME-EVERY-MINUTE-FOR-5-MIN/m-p/561579#M157247</guid>
      <dc:creator>elisas</dc:creator>
      <dc:date>2019-05-25T17:32:45Z</dc:date>
    </item>
  </channel>
</rss>

