<?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: Array to group time variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Array-to-group-time-variable/m-p/605489#M175742</link>
    <description>I suspect you're trying to scaffold a data set, ie see how many people are active at each hour of the day given the start and end time? If so, yes, there are easier ways. If you post some example data and expected output someone can help you further with this issue. &lt;BR /&gt;&lt;BR /&gt;Feel free to make up data if needed.</description>
    <pubDate>Tue, 19 Nov 2019 18:57:22 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-11-19T18:57:22Z</dc:date>
    <item>
      <title>Array to group time variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-to-group-time-variable/m-p/605484#M175740</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to re-categorize a time variable so that I can query how many the frequency of use of a medical device for each hour of the day.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to figure out how to put the following code in an array format so that I do not have to type this out 24 times (for each of the 24 hours of the day), but I am still pretty new to using arrays so I have not been able to figure it out.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data v2; set v1;&lt;/P&gt;&lt;P&gt;select;&lt;BR /&gt;when ("00:00:00"t &amp;lt;= start_time &amp;lt; "1:00:00"t) hour=1;&lt;BR /&gt;when ("01:00:00"t &amp;lt;= start_time&amp;lt; "2:00:00"t) hour=2;&lt;BR /&gt;/*[... etc until hour=24]*/&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there an easier way to do this?&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 18:42:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-to-group-time-variable/m-p/605484#M175740</guid>
      <dc:creator>fordcr2</dc:creator>
      <dc:date>2019-11-19T18:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: Array to group time variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-to-group-time-variable/m-p/605489#M175742</link>
      <description>I suspect you're trying to scaffold a data set, ie see how many people are active at each hour of the day given the start and end time? If so, yes, there are easier ways. If you post some example data and expected output someone can help you further with this issue. &lt;BR /&gt;&lt;BR /&gt;Feel free to make up data if needed.</description>
      <pubDate>Tue, 19 Nov 2019 18:57:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-to-group-time-variable/m-p/605489#M175742</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-11-19T18:57:22Z</dc:date>
    </item>
    <item>
      <title>Re: Array to group time variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-to-group-time-variable/m-p/605491#M175744</link>
      <description>&lt;P&gt;No arrays needed here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the HOUR. format, and so the time of 08:43 will be converted to 8 and the time of 19:07 will be converted to 19 and so on. Almost every SAS analysis procedure will work with the formatted value rather than the original unformatted value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another thought is to simply take the time and using mathematics, turn it into an integer. Since time is measured in seconds after midnight, this code will do what you wan&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;newtime=floor(time/3600);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Nov 2019 18:59:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-to-group-time-variable/m-p/605491#M175744</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-11-19T18:59:53Z</dc:date>
    </item>
    <item>
      <title>Re: Array to group time variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-to-group-time-variable/m-p/605493#M175746</link>
      <description>&lt;P&gt;That works - thanks!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 19:01:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-to-group-time-variable/m-p/605493#M175746</guid>
      <dc:creator>fordcr2</dc:creator>
      <dc:date>2019-11-19T19:01:48Z</dc:date>
    </item>
    <item>
      <title>Re: Array to group time variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-to-group-time-variable/m-p/605496#M175748</link>
      <description>&lt;P&gt;No need to use "magic" numbers in the code. You can use a time literal to figure how many seconds are in an hour.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;newtime=floor(time/'01:00't);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Nov 2019 19:24:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-to-group-time-variable/m-p/605496#M175748</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-19T19:24:02Z</dc:date>
    </item>
  </channel>
</rss>

