<?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: Time duration in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Time-duration/m-p/616771#M180625</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/293494"&gt;@Suzy_Cat&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could get your duration time with less effort by using the hour format. Here is a code snippet with the code in a data step and the same code in macro language without a data step&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let STARTTIME =%sysfunc(time());

* Project running...;

* Data step; 
data test;
	DURATION = put(time()-&amp;amp;STARTTIME,hour5.2)||'Hr';
	put DURATION=;
run;

* Macro code;
%let DURATION = %sysfunc(putn(%sysevalf(%sysfunc(time())-&amp;amp;STARTTIME),hour5.2))Hr;
%put &amp;amp;=DURATION;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 12 Jan 2020 11:04:20 GMT</pubDate>
    <dc:creator>ErikLund_Jensen</dc:creator>
    <dc:date>2020-01-12T11:04:20Z</dc:date>
    <item>
      <title>Time duration</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Time-duration/m-p/616758#M180620</link>
      <description>&lt;P&gt;Hi , I need count the duration for how long it take the project to run and show the result in the format "2hr30min" or "2h30m" or "2.5Hr" if the project completed in 2.5 hours. However, I could not figure out how to make the result correctly showing as how long it took the project to run. Can anyone give me a hand?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; STARTTIME =&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(time());&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; want;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;STARTTIME=&amp;amp;STARTTIME;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;EndTIME=&amp;amp;STARTTIME+90&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;00&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Duration=&amp;amp;EndTIME-&amp;amp;STARTTIME;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; STARTTIME EndTIME &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;time.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; Duration $&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;?.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jan 2020 06:08:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Time-duration/m-p/616758#M180620</guid>
      <dc:creator>Suzy_Cat</dc:creator>
      <dc:date>2020-01-12T06:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: Time duration</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Time-duration/m-p/616759#M180621</link>
      <description>&lt;P&gt;getting closer....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;STARTTIME=&amp;amp;STARTTIME;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;EndTIME=&amp;amp;STARTTIME+&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;9000&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Duration=&amp;amp;EndTIME-&amp;amp;STARTTIME;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;minute=INTCK(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'minute'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,STARTTIME,EndTIME );&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;hour=mod(minute/&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;60&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;60&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; STARTTIME EndTIME &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;time.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jan 2020 06:20:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Time-duration/m-p/616759#M180621</guid>
      <dc:creator>Suzy_Cat</dc:creator>
      <dc:date>2020-01-12T06:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: Time duration</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Time-duration/m-p/616760#M180622</link>
      <description>&lt;P&gt;Looks like I got there successfully...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; STARTTIME =&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(time());&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; want;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;STARTTIME=&amp;amp;STARTTIME;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;EndTIME=&amp;amp;STARTTIME+&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;12400&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Duration=&amp;amp;EndTIME-&amp;amp;STARTTIME;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;minute=INTCK(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'minute'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,STARTTIME,EndTIME );&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;hour=mod(minute/&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;60&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;60&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;dur=put(hour,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;4.1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;)!!&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"Hr"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; STARTTIME EndTIME &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;time.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jan 2020 06:28:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Time-duration/m-p/616760#M180622</guid>
      <dc:creator>Suzy_Cat</dc:creator>
      <dc:date>2020-01-12T06:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: Time duration</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Time-duration/m-p/616771#M180625</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/293494"&gt;@Suzy_Cat&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could get your duration time with less effort by using the hour format. Here is a code snippet with the code in a data step and the same code in macro language without a data step&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let STARTTIME =%sysfunc(time());

* Project running...;

* Data step; 
data test;
	DURATION = put(time()-&amp;amp;STARTTIME,hour5.2)||'Hr';
	put DURATION=;
run;

* Macro code;
%let DURATION = %sysfunc(putn(%sysevalf(%sysfunc(time())-&amp;amp;STARTTIME),hour5.2))Hr;
%put &amp;amp;=DURATION;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 12 Jan 2020 11:04:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Time-duration/m-p/616771#M180625</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2020-01-12T11:04:20Z</dc:date>
    </item>
    <item>
      <title>Re: Time duration</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Time-duration/m-p/616813#M180647</link>
      <description>This is exactly what I wanted to achieve! Thank you sooo much for the help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Sun, 12 Jan 2020 20:40:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Time-duration/m-p/616813#M180647</guid>
      <dc:creator>Suzy_Cat</dc:creator>
      <dc:date>2020-01-12T20:40:41Z</dc:date>
    </item>
  </channel>
</rss>

