<?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 EPOCH to second conversion in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/EPOCH-to-second-conversion/m-p/625472#M184356</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to convert the below from sql to SAS code in my proc sql statement.&amp;nbsp; Any ideas?&amp;nbsp; It seems to not like the&amp;nbsp; '% 86400' when converting to seconds.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table AMI_test as&lt;/P&gt;&lt;P&gt;select lp.epoch_interval_time,&lt;/P&gt;&lt;P&gt;((lp.epoch_interval_time -7*3600) % 86400) div 3600 as intv_hr,&lt;BR /&gt;(((lp.epoch_interval_time -7*3600) % 86400) div 3600) +1 as intrvl_24hr_ending&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Dan&lt;/P&gt;</description>
    <pubDate>Mon, 17 Feb 2020 23:25:02 GMT</pubDate>
    <dc:creator>dkassis</dc:creator>
    <dc:date>2020-02-17T23:25:02Z</dc:date>
    <item>
      <title>EPOCH to second conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/EPOCH-to-second-conversion/m-p/625472#M184356</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to convert the below from sql to SAS code in my proc sql statement.&amp;nbsp; Any ideas?&amp;nbsp; It seems to not like the&amp;nbsp; '% 86400' when converting to seconds.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table AMI_test as&lt;/P&gt;&lt;P&gt;select lp.epoch_interval_time,&lt;/P&gt;&lt;P&gt;((lp.epoch_interval_time -7*3600) % 86400) div 3600 as intv_hr,&lt;BR /&gt;(((lp.epoch_interval_time -7*3600) % 86400) div 3600) +1 as intrvl_24hr_ending&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Dan&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2020 23:25:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/EPOCH-to-second-conversion/m-p/625472#M184356</guid>
      <dc:creator>dkassis</dc:creator>
      <dc:date>2020-02-17T23:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: EPOCH to second conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/EPOCH-to-second-conversion/m-p/625475#M184358</link>
      <description>&lt;P&gt;3600 is the number of seconds in an hour, so you are dealing with datetimes (counted in seconds).&lt;/P&gt;
&lt;P&gt;So you don't need to convert to seconds.&lt;/P&gt;
&lt;P&gt;% is the modulo operator right?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;divide&amp;nbsp;( mod ( lp.epoch_interval_time - 7*3600 , 86400 ), 3600 ) as intv_hr,&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;should do what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2020 00:26:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/EPOCH-to-second-conversion/m-p/625475#M184358</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-02-18T00:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: EPOCH to second conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/EPOCH-to-second-conversion/m-p/625478#M184360</link>
      <description>&lt;P&gt;Thanks, that worked!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2020 01:00:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/EPOCH-to-second-conversion/m-p/625478#M184360</guid>
      <dc:creator>dkassis</dc:creator>
      <dc:date>2020-02-18T01:00:56Z</dc:date>
    </item>
    <item>
      <title>Re: EPOCH to second conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/EPOCH-to-second-conversion/m-p/625479#M184361</link>
      <description>&lt;P&gt;What do you think the percent is doing as an operator in that expression?&amp;nbsp; Is it MOD ?&amp;nbsp; SAS has a MOD() function.&lt;/P&gt;
&lt;P&gt;What are those "magic" numbers?&lt;/P&gt;
&lt;P&gt;What is 3600? Is it the number of seconds in an hour?&amp;nbsp; 60sec/min*60min/hr=3,600sec/hr.&lt;/P&gt;
&lt;P&gt;If you want the number of seconds in an hour use '01:00:00't&lt;/P&gt;
&lt;P&gt;What is 86400?&amp;nbsp; Is it the number of seconds in a day? 24hr/day*3,600sec/hr=86,400sec/hr&lt;/P&gt;
&lt;P&gt;If you want the number of seconds in 24 hours use '24:00:00't&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But what is the formula trying to actually do?&amp;nbsp; Is it subtracting 7 hours? Taking the time since midnight and then hours since midnight?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;hour(datepart(intnx('hour',lp.epoch_interval_time,-7,'same')))&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Feb 2020 01:07:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/EPOCH-to-second-conversion/m-p/625479#M184361</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-02-18T01:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: EPOCH to second conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/EPOCH-to-second-conversion/m-p/625488#M184368</link>
      <description>&lt;P&gt;The&amp;nbsp; mod() takes out all the (full) days, then subtract 7 hours, then transform time to (decimal) day.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I agree that these numbers could be better shown as proper durations such as&amp;nbsp;&lt;SPAN&gt;'01:00:00't&amp;nbsp; rather&amp;nbsp;than the&amp;nbsp;underlying count.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The intent here is to change unit though, so maybe showing the raw figure makes this intent more obvious. Maybe.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This might be the best balance?&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token function"&gt;divide&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;mod&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;lp&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;epoch_interval_time &lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;'07:00:00't&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;'24:00:00't&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;3600&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; as INTV_HR&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2020 02:20:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/EPOCH-to-second-conversion/m-p/625488#M184368</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-02-18T02:20:18Z</dc:date>
    </item>
  </channel>
</rss>

