<?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 Calculating total hours between two timestamps and excluding 24 hours each for holidays and weekends in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Calculating-total-hours-between-two-timestamps-and-excluding-24/m-p/617088#M19003</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have been breaking my head trying to get this to work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set with two datetime columns and another dataset with list of holidays and weekends.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to calculate the total hours between the two datetimes - and if any holiday and/or weekend falls between these dates, that day(24hours) needs to be removed from the total.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help me with the easiest way to do it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I am working with in terms of logic:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data want;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set have;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;var1=0;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;array hol(*) hol1-hol141;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;do i=1 to dim(hol);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if hol(i) ge datepart(datetime1) and hol(i) le datepart(datetime2) then&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;var1+24;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Net_hours=(intck('seconds', datetime1, datetime2)/(60*60)) - var1;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Jan 2020 22:59:48 GMT</pubDate>
    <dc:creator>sas1011</dc:creator>
    <dc:date>2020-01-13T22:59:48Z</dc:date>
    <item>
      <title>Calculating total hours between two timestamps and excluding 24 hours each for holidays and weekends</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculating-total-hours-between-two-timestamps-and-excluding-24/m-p/617088#M19003</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have been breaking my head trying to get this to work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set with two datetime columns and another dataset with list of holidays and weekends.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to calculate the total hours between the two datetimes - and if any holiday and/or weekend falls between these dates, that day(24hours) needs to be removed from the total.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help me with the easiest way to do it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I am working with in terms of logic:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data want;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set have;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;var1=0;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;array hol(*) hol1-hol141;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;do i=1 to dim(hol);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if hol(i) ge datepart(datetime1) and hol(i) le datepart(datetime2) then&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;var1+24;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Net_hours=(intck('seconds', datetime1, datetime2)/(60*60)) - var1;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 22:59:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculating-total-hours-between-two-timestamps-and-excluding-24/m-p/617088#M19003</guid>
      <dc:creator>sas1011</dc:creator>
      <dc:date>2020-01-13T22:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating total hours between two timestamps and excluding 24 hours each for holidays and week</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculating-total-hours-between-two-timestamps-and-excluding-24/m-p/617089#M19004</link>
      <description>&lt;P&gt;Do any of your datetime values occur &lt;EM&gt;&lt;STRONG&gt;within&lt;/STRONG&gt;&lt;/EM&gt; a holiday or weekend?&amp;nbsp; And if so, do you then need to subtract only a corresponding fraction of the 24 hours?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 23:13:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculating-total-hours-between-two-timestamps-and-excluding-24/m-p/617089#M19004</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-01-13T23:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating total hours between two timestamps and excluding 24 hours each for holidays and week</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Calculating-total-hours-between-two-timestamps-and-excluding-24/m-p/617090#M19005</link>
      <description>&lt;P&gt;Although you're doing hours, this is probably the same question:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Finding-the-next-working-day-with-a-custom-calendar/td-p/477859" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/Finding-the-next-working-day-with-a-custom-calendar/td-p/477859&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You really do want to create a custom calendar though, it'll save you a lot of time and headache once you get it working. It's tedious but not complicated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is perhaps the better reference:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/SAS-Tip-Generating-Holiday-Lists/ta-p/557799?title=Generating_Holiday_Lists" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/SAS-Tip-Generating-Holiday-Lists/ta-p/557799?title=Generating_Holiday_Lists&lt;/A&gt;&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/285490"&gt;@sas1011&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have been breaking my head trying to get this to work.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a data set with two datetime columns and another dataset with list of holidays and weekends.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to calculate the total hours between the two datetimes - and if any holiday and/or weekend falls between these dates, that day(24hours) needs to be removed from the total.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help me with the easiest way to do it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is what I am working with in terms of logic:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data want;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;set have;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;var1=0;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;array hol(*) hol1-hol141;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;do i=1 to dim(hol);&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;if hol(i) ge datepart(datetime1) and hol(i) le datepart(datetime2) then&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;var1+24;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Net_hours=(intck('seconds', datetime1, datetime2)/(60*60)) - var1;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 23:32:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Calculating-total-hours-between-two-timestamps-and-excluding-24/m-p/617090#M19005</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-01-13T23:32:45Z</dc:date>
    </item>
  </channel>
</rss>

