<?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: Get hour and minutes of the (current time minus 20 second) into macro variables? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Get-hour-and-minutes-of-the-current-time-minus-20-second-into/m-p/841574#M332760</link>
    <description>Have you tried&lt;BR /&gt;&lt;BR /&gt;%let now = %sysfunc(time() ) - 20;&lt;BR /&gt;&lt;BR /&gt;The other statements probably figure out to perform the math without even adding %eval</description>
    <pubDate>Mon, 31 Oct 2022 04:51:17 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2022-10-31T04:51:17Z</dc:date>
    <item>
      <title>Get hour and minutes of the (current time minus 20 second) into macro variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-hour-and-minutes-of-the-current-time-minus-20-second-into/m-p/841569#M332758</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I want to put hour and minute of the time 20 second before current time into macro variable.&lt;/P&gt;
&lt;P&gt;The code below might convey my idea better.&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;%let now=%sysfunc(time()       MINUS 20 SECOND);
%let hh=%sysfunc(hour(&amp;amp;now),z2.);
%let mm=%sysfunc(minute(&amp;amp;now),z2.);

%put &amp;amp;hh &amp;amp;mm;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Oct 2022 03:36:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-hour-and-minutes-of-the-current-time-minus-20-second-into/m-p/841569#M332758</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2022-10-31T03:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: Get hour and minutes of the (current time minus 20 second) into macro variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-hour-and-minutes-of-the-current-time-minus-20-second-into/m-p/841574#M332760</link>
      <description>Have you tried&lt;BR /&gt;&lt;BR /&gt;%let now = %sysfunc(time() ) - 20;&lt;BR /&gt;&lt;BR /&gt;The other statements probably figure out to perform the math without even adding %eval</description>
      <pubDate>Mon, 31 Oct 2022 04:51:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-hour-and-minutes-of-the-current-time-minus-20-second-into/m-p/841574#M332760</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2022-10-31T04:51:17Z</dc:date>
    </item>
    <item>
      <title>Re: Get hour and minutes of the (current time minus 20 second) into macro variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-hour-and-minutes-of-the-current-time-minus-20-second-into/m-p/841582#M332764</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;I think you forgot to evaluate the expression. Otherwise, the - 20 part is just text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let now = %sysevalf(%sysfunc(time()) - 20);

%put &amp;amp;=now.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Oct 2022 07:54:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-hour-and-minutes-of-the-current-time-minus-20-second-into/m-p/841582#M332764</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-10-31T07:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: Get hour and minutes of the (current time minus 20 second) into macro variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-hour-and-minutes-of-the-current-time-minus-20-second-into/m-p/841592#M332769</link>
      <description>I didn't worry about the text, since I expected the subsequent functions could utilize that text. What I do worry about is the first 20 seconds after midnight, and whether greater care would be needed to calculate properly. I can't check this sort of detail since it has been 4 years now that I have used a computer that actually has SAS on it.</description>
      <pubDate>Mon, 31 Oct 2022 09:56:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-hour-and-minutes-of-the-current-time-minus-20-second-into/m-p/841592#M332769</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2022-10-31T09:56:12Z</dc:date>
    </item>
    <item>
      <title>Re: Get hour and minutes of the (current time minus 20 second) into macro variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-hour-and-minutes-of-the-current-time-minus-20-second-into/m-p/841646#M332804</link>
      <description>&lt;P&gt;I did try -20 and SAS give following error.&lt;/P&gt;
&lt;P&gt;I should have included it in the original post.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1627  %let now=%sysfunc(time()       - 20);
ERROR: Expected close parenthesis after macro function invocation not found.
1628  %let hh=%sysfunc(hour(&amp;amp;now),z2.);
1629  %let mm=%sysfunc(minute(&amp;amp;now),z2.);
1630
1631  %put &amp;amp;hh &amp;amp;mm;
0,z2.) 0,z2.)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Oct 2022 13:44:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-hour-and-minutes-of-the-current-time-minus-20-second-into/m-p/841646#M332804</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2022-10-31T13:44:21Z</dc:date>
    </item>
    <item>
      <title>Re: Get hour and minutes of the (current time minus 20 second) into macro variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-hour-and-minutes-of-the-current-time-minus-20-second-into/m-p/841650#M332806</link>
      <description>&lt;P&gt;As shown in the log, your parentheses are wrong.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to use parentheses around %sysfunc(time()).&amp;nbsp; That will return a number with a decimal in it (number of seconds since midnight).&amp;nbsp; Then if you want to subtract 20 from that value, you need %sysevalf, as shown by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let now=%sysevalf( %sysfunc(time()) - 20);
%let hh=%sysfunc(hour(&amp;amp;now),z2.);
%let mm=%sysfunc(minute(&amp;amp;now),z2.);
%put &amp;amp;=now &amp;amp;=hh &amp;amp;=mm ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Actually, as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;pointed out the %sysevalf is not essential here, as the HOUR function is happy to take an expression as its argument, so you can do stuff like:&lt;/P&gt;
&lt;PRE&gt;1    %put %sysfunc(hour(3600.5-20),z2.);
00
2    %put %sysfunc(minute(3600.5-20),z2.);
59
&lt;/PRE&gt;
&lt;P&gt;And to answer the question about negative values, they are not a problem.&amp;nbsp; A negative value for a SAS time is seconds before midnight:&lt;/P&gt;
&lt;PRE&gt;4    %put %sysfunc(hour(5-20),z2.);
23
5    %put %sysfunc(minute(5-20),z2.);
59
&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Oct 2022 14:04:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-hour-and-minutes-of-the-current-time-minus-20-second-into/m-p/841650#M332806</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-10-31T14:04:22Z</dc:date>
    </item>
    <item>
      <title>Re: Get hour and minutes of the (current time minus 20 second) into macro variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-hour-and-minutes-of-the-current-time-minus-20-second-into/m-p/841660#M332812</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I posted the solution originally, I had the parentheses wrong.&amp;nbsp; Probably,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/49486"&gt;@hhchenfx&lt;/a&gt;&amp;nbsp;copied that original post and didn't get notified about the correction I had made.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Still, I'm not sure what happens when we hit just after midnight.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2022 14:38:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-hour-and-minutes-of-the-current-time-minus-20-second-into/m-p/841660#M332812</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2022-10-31T14:38:33Z</dc:date>
    </item>
    <item>
      <title>Re: Get hour and minutes of the (current time minus 20 second) into macro variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-hour-and-minutes-of-the-current-time-minus-20-second-into/m-p/841663#M332815</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;, 5 seconds after midnight time() will return 5, so 5-20 will be negative, but it works and returns 23:59.&amp;nbsp; That was what I was trying to show with this example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;4    %put %sysfunc(hour(5-20),z2.);
23
5    %put %sysfunc(minute(5-20),z2.);
59
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2022 14:49:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-hour-and-minutes-of-the-current-time-minus-20-second-into/m-p/841663#M332815</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-10-31T14:49:22Z</dc:date>
    </item>
  </channel>
</rss>

