<?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: how many times a specific time of day occurs in a datetime interval in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-many-times-a-specific-time-of-day-occurs-in-a-datetime/m-p/791998#M253764</link>
    <description>&lt;P&gt;If your test is to see how many times midnight is in the interval, then the INTCK function does the job.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    incl_midnight = intck('dtday',begdate,enddate);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want some other time, let's say 10:45pm, I believe (untested), you subtract '22:45:00't from both begdate and enddate and then use the INTCK function.&lt;/P&gt;</description>
    <pubDate>Mon, 24 Jan 2022 21:27:12 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-01-24T21:27:12Z</dc:date>
    <item>
      <title>how many times a specific time of day occurs in a datetime interval</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-many-times-a-specific-time-of-day-occurs-in-a-datetime/m-p/791993#M253761</link>
      <description>&lt;P&gt;How do you count the number of times a specific time of day (for example&amp;nbsp;23:59, i.e. 11:59PM) occurs in a datetime interval?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;  
	input ID $ begDate:datetime13. endDate:datetime13.;
	format begDate endDate datetime13.;
cards;
aaa 10NOV19:01:49 10NOV19:03:49
bbb 10NOV19:22:49 11NOV19:03:49
ccc 10NOV19:22:49 12NOV19:03:49
	;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rommel_0-1643058550135.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67695iEFCB349818D24B6E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="rommel_0-1643058550135.png" alt="rommel_0-1643058550135.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jan 2022 21:10:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-many-times-a-specific-time-of-day-occurs-in-a-datetime/m-p/791993#M253761</guid>
      <dc:creator>dataMart87</dc:creator>
      <dc:date>2022-01-24T21:10:57Z</dc:date>
    </item>
    <item>
      <title>Re: how many times a specific time of day occurs in a datetime interval</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-many-times-a-specific-time-of-day-occurs-in-a-datetime/m-p/791997#M253763</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/2725"&gt;@dataMart87&lt;/a&gt;&amp;nbsp;, it may depend on what your use case is but an easy method would be to use the TIMEPART() function then do a count distinct. See example below&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*Load data;
data have;  
	input ID $ begDate:datetime13. endDate:datetime13.;
	format begDate endDate datetime13.;
cards;
aaa 10NOV19:01:49 10NOV19:03:49
bbb 10NOV19:22:49 11NOV19:03:49
ccc 10NOV19:22:49 12NOV19:03:49
	;
run;

*Extract time;
data want;
set have;
begTimePart = timepart(begDate);
format begTimePart time.;
run;

*Get count of time appearance;
proc sql;select distinct begTimePart,count(begTimePart) 
from work.want group by begTimePart;quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Jan 2022 21:26:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-many-times-a-specific-time-of-day-occurs-in-a-datetime/m-p/791997#M253763</guid>
      <dc:creator>HarrySnart</dc:creator>
      <dc:date>2022-01-24T21:26:50Z</dc:date>
    </item>
    <item>
      <title>Re: how many times a specific time of day occurs in a datetime interval</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-many-times-a-specific-time-of-day-occurs-in-a-datetime/m-p/791998#M253764</link>
      <description>&lt;P&gt;If your test is to see how many times midnight is in the interval, then the INTCK function does the job.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    incl_midnight = intck('dtday',begdate,enddate);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want some other time, let's say 10:45pm, I believe (untested), you subtract '22:45:00't from both begdate and enddate and then use the INTCK function.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jan 2022 21:27:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-many-times-a-specific-time-of-day-occurs-in-a-datetime/m-p/791998#M253764</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-01-24T21:27:12Z</dc:date>
    </item>
  </channel>
</rss>

