<?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: Check if current time less than a value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Check-if-current-time-less-than-a-value/m-p/910174#M358967</link>
    <description>&lt;P&gt;Thank you so much for helping!&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;</description>
    <pubDate>Tue, 02 Jan 2024 22:47:11 GMT</pubDate>
    <dc:creator>hhchenfx</dc:creator>
    <dc:date>2024-01-02T22:47:11Z</dc:date>
    <item>
      <title>Check if current time less than a value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-if-current-time-less-than-a-value/m-p/910163#M358960</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I want to compare current time with '4:55't as below but my code is not working.&lt;/P&gt;
&lt;P&gt;Can you please help to fix?&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 _BREAK() ;
%let current_time = time(); /* Get the current time */

%IF &amp;amp;current_time &amp;lt; '4:55't %then %do;
	%put "print before ";
	%END;
%ELSE %do;
	%put "print after";
	%END;

%Mend;

%_BREAK();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2024 21:09:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-if-current-time-less-than-a-value/m-p/910163#M358960</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2024-01-02T21:09:31Z</dc:date>
    </item>
    <item>
      <title>Re: Check if current time less than a value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-if-current-time-less-than-a-value/m-p/910166#M358961</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let current_time = time(); /* Get the current time */
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here, you assign the&amp;nbsp;&lt;U&gt;text&lt;/U&gt; time() to the macro variable (not the result of the function!). If you want to execute a data step function in macro code, you need to use %SYSFUNC:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let current_time = %sysfunc(time());&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Jan 2024 21:17:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-if-current-time-less-than-a-value/m-p/910166#M358961</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-01-02T21:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: Check if current time less than a value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-if-current-time-less-than-a-value/m-p/910167#M358962</link>
      <description>&lt;P&gt;It's a lot easier not using macro logic - not sure why you need a macro at all:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO _BREAK() ;

data _null_;
  if time() &amp;lt; '4:55't then putlog "print before ";
  else putlog "print after";
run;

%Mend;

%_BREAK();&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Jan 2024 21:24:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-if-current-time-less-than-a-value/m-p/910167#M358962</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2024-01-02T21:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: Check if current time less than a value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-if-current-time-less-than-a-value/m-p/910168#M358963</link>
      <description>&lt;P&gt;Greetings,&lt;/P&gt;
&lt;P&gt;I made the following modifications to your code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;%MACRO _BREAK() ;&lt;/DIV&gt;
&lt;DIV&gt;%let current_time = %sysfunc(time()); /* Get the current time */&lt;/DIV&gt;
&lt;DIV&gt;%put curr is &amp;amp;current_time;&lt;/DIV&gt;
&lt;DIV&gt;%IF %sysevalf(&amp;amp;current_time &amp;lt; '20:55't) %then %do;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; %put "print before ";&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; %END;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;%ELSE %do;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; %put "print after";&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; %END;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;%Mend;&lt;/DIV&gt;
&lt;DIV&gt;%_BREAK();&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;The problems you were having are due to the macro facility only understanding text.&lt;/DIV&gt;</description>
      <pubDate>Tue, 02 Jan 2024 21:32:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-if-current-time-less-than-a-value/m-p/910168#M358963</guid>
      <dc:creator>LynnP_sas</dc:creator>
      <dc:date>2024-01-02T21:32:31Z</dc:date>
    </item>
    <item>
      <title>Re: Check if current time less than a value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-if-current-time-less-than-a-value/m-p/910174#M358967</link>
      <description>&lt;P&gt;Thank you so much for helping!&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2024 22:47:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-if-current-time-less-than-a-value/m-p/910174#M358967</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2024-01-02T22:47:11Z</dc:date>
    </item>
  </channel>
</rss>

