<?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: Count Summary by time (Hours) in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Count-Summary-by-time-Hours/m-p/405130#M66962</link>
    <description>&lt;P&gt;I think I was overthinking it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you both for the responses;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 18 Oct 2017 08:42:48 GMT</pubDate>
    <dc:creator>Stretlow</dc:creator>
    <dc:date>2017-10-18T08:42:48Z</dc:date>
    <item>
      <title>Count Summary by time (Hours)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Count-Summary-by-time-Hours/m-p/405118#M66959</link>
      <description>&lt;P&gt;Hi There.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a large data set and the records have a Time variable in the format Time8.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What i'm trying to do is do a summary count by hour, so if the time is 0:07:01 then that would be in the hour summary of 0:00:00 to 1:00:00&lt;/P&gt;
&lt;P&gt;and i'm not sure of the best way to do it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've tried using an intck function but have been unsuccessful so far.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Stret&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2017 08:00:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Count-Summary-by-time-Hours/m-p/405118#M66959</guid>
      <dc:creator>Stretlow</dc:creator>
      <dc:date>2017-10-18T08:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: Count Summary by time (Hours)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Count-Summary-by-time-Hours/m-p/405123#M66960</link>
      <description>&lt;P&gt;Create a new variable that normalizes your data to the hour, using the fact that SAS times are counts of seconds:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input mytime time8.;
format mytime time8.;
cards;
11:32:44
12:33:22
12:45:56
13:16:08
13:25:00
;
run;

data have1;
set have;
hours = int(mytime/3600)*3600;
format hours time8.;
run;

proc summary data=have1 n nway;
class hours;
output out=want (drop=_:) n(mytime)=count;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Oct 2017 08:22:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Count-Summary-by-time-Hours/m-p/405123#M66960</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-18T08:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: Count Summary by time (Hours)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Count-Summary-by-time-Hours/m-p/405124#M66961</link>
      <description>&lt;P&gt;What part are you unsure about?&amp;nbsp; To me the problem is a simple one:&lt;/P&gt;
&lt;P&gt;1) Create a variable called hour, and window your times into a categorical variable&lt;/P&gt;
&lt;P&gt;2) Do you calculations based on the cat hour&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  hr=hour(yourtime) + 1;
run;

proc means data=want;
  by hour;
...
&lt;/PRE&gt;
&lt;P&gt;So the hour function returns the hour from a time variable, which will be 0 for everything up to 1:00:00, then 1 etc. So add 1 to that.&amp;nbsp; If thats not exactly what you want then maybe a select clause for each condition.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2017 08:25:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Count-Summary-by-time-Hours/m-p/405124#M66961</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-18T08:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: Count Summary by time (Hours)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Count-Summary-by-time-Hours/m-p/405130#M66962</link>
      <description>&lt;P&gt;I think I was overthinking it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you both for the responses;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2017 08:42:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Count-Summary-by-time-Hours/m-p/405130#M66962</guid>
      <dc:creator>Stretlow</dc:creator>
      <dc:date>2017-10-18T08:42:48Z</dc:date>
    </item>
    <item>
      <title>Re: Count Summary by time (Hours)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Count-Summary-by-time-Hours/m-p/405218#M66963</link>
      <description>&lt;P&gt;With date, time and datetime values sometimes all you need is a careful choice of format:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
input mytime time8.;
format mytime time8.;
cards;
11:32:44
12:33:22
12:45:56
13:16:08
13:25:00
00:07:15
04:21:09
;
run;

proc summary data=have n nway;
class mytime;
format mytime  hhmm2.;
output out=want (drop=_:) n(mytime)=count;
run;

&lt;/PRE&gt;
&lt;P&gt;Note that the resulting values of mytime in the want set are still time values, but the format displays only the hour portion. The actual value will usually be the smallest in the interval as "rounded" by the format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2017 14:14:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Count-Summary-by-time-Hours/m-p/405218#M66963</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-10-18T14:14:40Z</dc:date>
    </item>
  </channel>
</rss>

