<?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: Running code when time between certain window in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Running-code-when-time-between-certain-window/m-p/863083#M340946</link>
    <description>&lt;P&gt;Set OPTIONS MPRINT; run your macro and share the result from the log.&lt;/P&gt;
&lt;P&gt;Note: "I thought the one below will do the job but it doesn't." is not very informative.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect, if that is your code that you posted is correct that one of two things is happening: you are getting a ERROR because the statement: time8 run; doesn't make any sense&lt;/P&gt;
&lt;PRE&gt;216  data a; set _NULL_;time8
                        -----
                        180
ERROR 180-322: Statement is not valid or it is used out of proper order.

217     run;
&lt;/PRE&gt;
&lt;P&gt;OR that the second bit is running because you are missing a RUN to end the data step. Until a data step boundary occurs in the second case the data step is "running" but not finished.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macro language treats everything as character so when you compare&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt; 15:00:00 &amp;lt; %sysfunc(time(),.0)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You are comparing a string of 15:00:00 to a different string and you need to address what the %sysfunc i actually returning (Hint: remove the format as length 0 formats don't work well for anything). If the time actually were 15:00:00 the result of %sysfunc(time()) would be 54000. When you place that into a .0 format you get an * as SAS can't fit that into that format at all. Maybe you though that TIME8 was on a different line???&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that any data step or procedure inside a macro really really needs an explicit RUN; as the timing for when a following boundary may be very problematic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/49486"&gt;@hhchenfx&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;My main macro will run every minute and inside that code, I want to run a small code just one time when time in between 15:00 - 15:01.&lt;/P&gt;
&lt;P&gt;Can you please help me to do it?&lt;/P&gt;
&lt;P&gt;I thought the one below will do the job but it doesn't.&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro try;
  %if  15:00:00 &amp;lt; %sysfunc(time(),.0) &amp;lt; 15:02:00 %then %do;
    data a; set _NULL_;time8
	run;
  %end;
  %else %do;
  	data b; set _NULL_;
  %end;
%mend;

%try;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 08 Mar 2023 22:28:38 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2023-03-08T22:28:38Z</dc:date>
    <item>
      <title>Running code when time between certain window</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-code-when-time-between-certain-window/m-p/863070#M340936</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;My main macro will run every minute and inside that code, I want to run a small code just one time when time in between 15:00 - 15:01.&lt;/P&gt;
&lt;P&gt;Can you please help me to do it?&lt;/P&gt;
&lt;P&gt;I thought the one below will do the job but it doesn't.&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro try;
  %if  15:00:00 &amp;lt; %sysfunc(time(),.0) &amp;lt; 15:02:00 %then %do;
    data a; set _NULL_;
	run;
  %end;
  %else %do;
  	data b; set _NULL_;
  %end;
%mend;

%try;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Mar 2023 22:19:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-code-when-time-between-certain-window/m-p/863070#M340936</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2023-03-08T22:19:36Z</dc:date>
    </item>
    <item>
      <title>Re: Running code when time between certain window</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-code-when-time-between-certain-window/m-p/863083#M340946</link>
      <description>&lt;P&gt;Set OPTIONS MPRINT; run your macro and share the result from the log.&lt;/P&gt;
&lt;P&gt;Note: "I thought the one below will do the job but it doesn't." is not very informative.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect, if that is your code that you posted is correct that one of two things is happening: you are getting a ERROR because the statement: time8 run; doesn't make any sense&lt;/P&gt;
&lt;PRE&gt;216  data a; set _NULL_;time8
                        -----
                        180
ERROR 180-322: Statement is not valid or it is used out of proper order.

217     run;
&lt;/PRE&gt;
&lt;P&gt;OR that the second bit is running because you are missing a RUN to end the data step. Until a data step boundary occurs in the second case the data step is "running" but not finished.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macro language treats everything as character so when you compare&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt; 15:00:00 &amp;lt; %sysfunc(time(),.0)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You are comparing a string of 15:00:00 to a different string and you need to address what the %sysfunc i actually returning (Hint: remove the format as length 0 formats don't work well for anything). If the time actually were 15:00:00 the result of %sysfunc(time()) would be 54000. When you place that into a .0 format you get an * as SAS can't fit that into that format at all. Maybe you though that TIME8 was on a different line???&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that any data step or procedure inside a macro really really needs an explicit RUN; as the timing for when a following boundary may be very problematic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/49486"&gt;@hhchenfx&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;My main macro will run every minute and inside that code, I want to run a small code just one time when time in between 15:00 - 15:01.&lt;/P&gt;
&lt;P&gt;Can you please help me to do it?&lt;/P&gt;
&lt;P&gt;I thought the one below will do the job but it doesn't.&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro try;
  %if  15:00:00 &amp;lt; %sysfunc(time(),.0) &amp;lt; 15:02:00 %then %do;
    data a; set _NULL_;time8
	run;
  %end;
  %else %do;
  	data b; set _NULL_;
  %end;
%mend;

%try;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 22:28:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-code-when-time-between-certain-window/m-p/863083#M340946</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-03-08T22:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: Running code when time between certain window</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-code-when-time-between-certain-window/m-p/863096#M340955</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;That time8 is a typo.&lt;/P&gt;
&lt;P&gt;I try to convert time to second but still the comparison fail, always return "data a"&amp;nbsp;even current time is&amp;nbsp;&lt;STRONG&gt;68102.7880001068 , which is outside the range of 67800-68000&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;31280 %macro try;
31281 %if 67800 &amp;lt; %sysfunc(time())&amp;lt;68000
31282 %then %do;
31283 data a; set _NULL_;
31284 run;
31285 %end;
31286 %else %do;
31287 data b; set _NULL_;
31288 %end;
31289 %put %sysfunc(time());
31290 %mend;
31291
31292 %try;

NOTE: The data set WORK.A has 0 observations and 0 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds


68102.7880001068

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 23:58:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-code-when-time-between-certain-window/m-p/863096#M340955</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2023-03-08T23:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: Running code when time between certain window</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-code-when-time-between-certain-window/m-p/863100#M340958</link>
      <description>&lt;P&gt;So somehow I have to break that a&amp;lt;b&amp;lt;c into a&amp;lt;b and b&amp;lt;c to get the IF THEN works.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%macro try;
  %if 67800 &amp;lt; %sysfunc(time()) AND %sysfunc(time())&amp;lt;78000
 %then %do;
    data a; set _NULL_;
	run;
  %end;
  %else %do;
  	data b; set _NULL_;
  %end;
  %put %sysfunc(time());
%mend;

%try;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Mar 2023 00:00:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-code-when-time-between-certain-window/m-p/863100#M340958</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2023-03-09T00:00:57Z</dc:date>
    </item>
    <item>
      <title>Re: Running code when time between certain window</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-code-when-time-between-certain-window/m-p/863145#M340971</link>
      <description>&lt;P&gt;I think this may work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro try;
  %local now;
  %let now=%sysfunc(time(),time8.);
  %if "&amp;amp;now"&amp;gt;"15:00:00" and "&amp;amp;now"&amp;lt;"15:02:00" %then %do;
 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Two points:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;It is better to use the formatted value for comparison, as it makes the code a lot easier to read. And the character comparison shown should work.&lt;/LI&gt;
&lt;LI&gt;a&amp;lt;b&amp;lt;c does not mean the same in SAS macro language as in the datastep. Instead it compares the boolean value (1 or 0) from the expression a&amp;lt;b with the value of c. You have to have two comparisons with AND here.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Thu, 09 Mar 2023 09:56:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-code-when-time-between-certain-window/m-p/863145#M340971</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2023-03-09T09:56:05Z</dc:date>
    </item>
    <item>
      <title>Re: Running code when time between certain window</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-code-when-time-between-certain-window/m-p/863238#M341011</link>
      <description>&lt;P&gt;You code and explanation is very much helpful.&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2023 17:59:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-code-when-time-between-certain-window/m-p/863238#M341011</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2023-03-09T17:59:02Z</dc:date>
    </item>
  </channel>
</rss>

