<?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: Loop until specified datetime in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Loop-until-specified-datetime/m-p/440504#M282530</link>
    <description>&lt;P&gt;&amp;nbsp;Hi again,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It works for me as well. &lt;STRONG&gt;So thank you very much for your help, really appreciate it&amp;nbsp;&lt;/STRONG&gt;!!! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Best,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;F.&lt;/P&gt;</description>
    <pubDate>Tue, 27 Feb 2018 13:58:45 GMT</pubDate>
    <dc:creator>ssomak</dc:creator>
    <dc:date>2018-02-27T13:58:45Z</dc:date>
    <item>
      <title>Loop until specified datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-until-specified-datetime/m-p/440469#M282525</link>
      <description>Dear all,

I would like to write a macro program, that will work until a given datetime (passed as a parameter). I wrote something like this:

%global current;

%macro test_loop(dt);
	data _null_;
		call symput('current', put(datetime(), best12.));
		%let end_dt=%sysfunc(inputn(&amp;amp;dt., datetime.));
	run;

	%do %until (&amp;amp;current.&amp;gt;&amp;amp;end_dt.);

/*		%include 'some_program.sas';*/

		data _null_;
			call symput('current', put(datetime(), best10.0));
			%put &amp;amp;current.;
		run;
	%end;
%mend test_loop;

%test_loop('27FEB2018:15:00:00');

But unfortunatelly it doesn't work. Can anyone help me please &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; ?

 Thanks in advance!</description>
      <pubDate>Tue, 27 Feb 2018 12:10:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-until-specified-datetime/m-p/440469#M282525</guid>
      <dc:creator>ssomak</dc:creator>
      <dc:date>2018-02-27T12:10:05Z</dc:date>
    </item>
    <item>
      <title>Re: Loop until specified datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-until-specified-datetime/m-p/440470#M282526</link>
      <description>&lt;P&gt;&amp;nbsp;Hi again,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something wrong went with formatting, so I paste my post again:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Dear all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to write a macro program, that will work until a given datetime. I wrote something like this:&lt;/P&gt;
&lt;P&gt;%global current;&lt;/P&gt;
&lt;P&gt;%macro test_loop(dt);&lt;BR /&gt; data _null_;&lt;BR /&gt; call symput('current', put(datetime(), best12.));&lt;BR /&gt; %let end_dt=%sysfunc(inputn(&amp;amp;dt., datetime.));&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;%do %until (&amp;amp;current.&amp;gt;&amp;amp;end_dt.);&lt;/P&gt;
&lt;P&gt;/* %include 'some_program.sas';*/&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt; call symput('current', put(datetime(), best10.0));&lt;BR /&gt; %put &amp;amp;current.;&lt;BR /&gt; run;&lt;BR /&gt; %end;&lt;BR /&gt;%mend test_loop;&lt;/P&gt;
&lt;P&gt;%test_loop('27FEB2018:15:00:00');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;But unfortunatelly it doesn't work. Can anyone help me please&amp;nbsp;&lt;/SPAN&gt;&lt;IMG class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" border="0" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;SPAN&gt;&amp;nbsp;? &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;Thanks in advance!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 12:12:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-until-specified-datetime/m-p/440470#M282526</guid>
      <dc:creator>ssomak</dc:creator>
      <dc:date>2018-02-27T12:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: Loop until specified datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-until-specified-datetime/m-p/440472#M282527</link>
      <description>&lt;P&gt;Please use the proper subwindow for posting code, and use visual formatting to make your code readable, like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%global current;

%macro test_loop(dt);

data _null_;
call symput('current', put(datetime(), best12.));
%let end_dt=%sysfunc(inputn(&amp;amp;dt., datetime.));
run;

%do %until (&amp;amp;current.&amp;gt;&amp;amp;end_dt.);

  /* %include 'some_program.sas';*/

  data _null_;
  call symput('current', put(datetime(), best10.0));
  %put &amp;amp;current.;
  run;

%end;

%mend test_loop;

%test_loop('27FEB2018:15:00:00');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And please define "doesn't work".&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 12:26:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-until-specified-datetime/m-p/440472#M282527</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-02-27T12:26:06Z</dc:date>
    </item>
    <item>
      <title>Re: Loop until specified datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-until-specified-datetime/m-p/440489#M282528</link>
      <description>&lt;P&gt;&amp;nbsp;Hi!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sure, I will use the proper subwindow (sorry, I didn't notice it before).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And&amp;nbsp;about the definition of "doesn't work". I thought that when I run this code, in every second there will be current datetime in the log:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symput('current', put(datetime(), best10.0));
%put &amp;amp;current.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But unfortunately there is the same value for first, let's say, 5 second, another value of next 5 second and so on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In general, I would like to achieve the following goal:&lt;/P&gt;
&lt;P&gt;at 2PM I call this macro in this way:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%test_loop('27FEB2018:16:00:00');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and&amp;nbsp;at 4PM it will stop work (because value of &lt;EM&gt;current&lt;/EM&gt; variable will be grater that value of &lt;EM&gt;end_dt&lt;/EM&gt; variable).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Best,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;F.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 13:00:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-until-specified-datetime/m-p/440489#M282528</guid>
      <dc:creator>ssomak</dc:creator>
      <dc:date>2018-02-27T13:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: Loop until specified datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-until-specified-datetime/m-p/440497#M282529</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%global current;

%macro test_loop(dt);

%let end_dt=%sysfunc(inputn(&amp;amp;dt., datetime.));
%put end_dt=&amp;amp;end_dt.;

data _null_;
call symput('current', put(datetime(), best12.));
run;

%do %until (&amp;amp;current.&amp;gt;&amp;amp;end_dt.);

  /* %include 'some_program.sas';*/

  data _null_;
  x =sleep(5,1);
  run;

  data _null_;
  call symput('current', put(datetime(), best10.0));
  run;
  
  %put &amp;amp;current.;
%end;

%mend test_loop;

%test_loop(%sysfunc(intnx(minute,%sysfunc(datetime()),1),datetime19.));
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;it works for me.&lt;/P&gt;
&lt;P&gt;The data _null_ with the sleep() is in there to prevent the creation of an oversized log (too many quick iterations).&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 13:31:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-until-specified-datetime/m-p/440497#M282529</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-02-27T13:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: Loop until specified datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-until-specified-datetime/m-p/440504#M282530</link>
      <description>&lt;P&gt;&amp;nbsp;Hi again,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It works for me as well. &lt;STRONG&gt;So thank you very much for your help, really appreciate it&amp;nbsp;&lt;/STRONG&gt;!!! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Best,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;F.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 13:58:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-until-specified-datetime/m-p/440504#M282530</guid>
      <dc:creator>ssomak</dc:creator>
      <dc:date>2018-02-27T13:58:45Z</dc:date>
    </item>
  </channel>
</rss>

