<?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: Select  the observation of every 1 minute in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Select-the-observation-of-every-1-minute/m-p/3651#M1561</link>
    <description>The simplest way is to add a second column to your table that contains the time rounded to the interval you want to select.  Here is some data to play with.&lt;BR /&gt;
&lt;BR /&gt;
Data TIMES;&lt;BR /&gt;
  Attrib  TIME  Length = 5  Format = Time8.;&lt;BR /&gt;
  TIME = "01:04:15"t;&lt;BR /&gt;
  Output;&lt;BR /&gt;
  TIME = "01:04:38"t;&lt;BR /&gt;
  Output;&lt;BR /&gt;
  TIME = "01:04:55"t;&lt;BR /&gt;
  Output;&lt;BR /&gt;
  TIME = "01:05:23"t;&lt;BR /&gt;
  Output;&lt;BR /&gt;
Run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
The data are in time order, and we will want the first record for each minute.  So let's pass this data to another step and find the time rounded down to the nearest minute.  There are many ways to do this, but I like the IntNx() function because it is so easy to work with.  By telling IntNx() to use intervals of minute, we will round to the nearest minute.  The directive "0" tells IntNx() that the minute shift is 0, that is the actual hour and minute values will be preserved.  The final directive "b" instructs IntNx() to calculate the Beginning of the time interval.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Data TIMESTRAT;&lt;BR /&gt;
  Set TIMES;&lt;BR /&gt;
  TIMEROUND = IntNx( "Minute", TIME, 0, "b");&lt;BR /&gt;
  Format TIMEROUND Time8.;&lt;BR /&gt;
Run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Your data are in order of TIMEROUND TIME, so you can select the first value for each time rounded to the nearest minute by specifying the order with a BY statement, and then select the First.TIMEROUND record.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Now here comes the really good bit of IntNx().  If instead of specifying "Minute" you specify "Minute15" all times will round down to the nearest 15 minute interval in the hour.&lt;BR /&gt;
&lt;BR /&gt;
Kind regards&lt;BR /&gt;
&lt;BR /&gt;
David</description>
    <pubDate>Fri, 29 Jun 2007 09:35:37 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2007-06-29T09:35:37Z</dc:date>
    <item>
      <title>Select  the observation of every 1 minute</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Select-the-observation-of-every-1-minute/m-p/3650#M1560</link>
      <description>hello&lt;BR /&gt;
I have a seri of data that contains time (hour : minute :second).&lt;BR /&gt;
how can I have just the observation of  every minute or every 15 minutes?&lt;BR /&gt;
(hint:I want to do it in proc step)</description>
      <pubDate>Thu, 28 Jun 2007 18:17:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Select-the-observation-of-every-1-minute/m-p/3650#M1560</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2007-06-28T18:17:03Z</dc:date>
    </item>
    <item>
      <title>Re: Select  the observation of every 1 minute</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Select-the-observation-of-every-1-minute/m-p/3651#M1561</link>
      <description>The simplest way is to add a second column to your table that contains the time rounded to the interval you want to select.  Here is some data to play with.&lt;BR /&gt;
&lt;BR /&gt;
Data TIMES;&lt;BR /&gt;
  Attrib  TIME  Length = 5  Format = Time8.;&lt;BR /&gt;
  TIME = "01:04:15"t;&lt;BR /&gt;
  Output;&lt;BR /&gt;
  TIME = "01:04:38"t;&lt;BR /&gt;
  Output;&lt;BR /&gt;
  TIME = "01:04:55"t;&lt;BR /&gt;
  Output;&lt;BR /&gt;
  TIME = "01:05:23"t;&lt;BR /&gt;
  Output;&lt;BR /&gt;
Run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
The data are in time order, and we will want the first record for each minute.  So let's pass this data to another step and find the time rounded down to the nearest minute.  There are many ways to do this, but I like the IntNx() function because it is so easy to work with.  By telling IntNx() to use intervals of minute, we will round to the nearest minute.  The directive "0" tells IntNx() that the minute shift is 0, that is the actual hour and minute values will be preserved.  The final directive "b" instructs IntNx() to calculate the Beginning of the time interval.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Data TIMESTRAT;&lt;BR /&gt;
  Set TIMES;&lt;BR /&gt;
  TIMEROUND = IntNx( "Minute", TIME, 0, "b");&lt;BR /&gt;
  Format TIMEROUND Time8.;&lt;BR /&gt;
Run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Your data are in order of TIMEROUND TIME, so you can select the first value for each time rounded to the nearest minute by specifying the order with a BY statement, and then select the First.TIMEROUND record.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Now here comes the really good bit of IntNx().  If instead of specifying "Minute" you specify "Minute15" all times will round down to the nearest 15 minute interval in the hour.&lt;BR /&gt;
&lt;BR /&gt;
Kind regards&lt;BR /&gt;
&lt;BR /&gt;
David</description>
      <pubDate>Fri, 29 Jun 2007 09:35:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Select-the-observation-of-every-1-minute/m-p/3651#M1561</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2007-06-29T09:35:37Z</dc:date>
    </item>
  </channel>
</rss>

