<?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 selecting Min Rate within a group of records in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/selecting-Min-Rate-within-a-group-of-records/m-p/48650#M10054</link>
    <description>For this example I need to check each row in the following table and determine the minimum rate for each group of records for the past 2 days. &lt;BR /&gt;
&lt;BR /&gt;
In reality I need to check the past 36 days...&lt;BR /&gt;
&lt;BR /&gt;
Product   Treatment    date                  rate&lt;BR /&gt;
================================&lt;BR /&gt;
M             H               2011-02-28        2.29  = 2.29          &lt;BR /&gt;
M             H               2011-03-01        2.19  = 2.19          &lt;BR /&gt;
M             H               2011-03-02        2.09  = 2.09                &lt;BR /&gt;
&lt;BR /&gt;
M             M               2011-02-28        3.39  = 3.39            &lt;BR /&gt;
M             M               2011-03-01        3.49  = 3.39          &lt;BR /&gt;
M             M               2011-03-02        3.59  = 3.39          &lt;BR /&gt;
&lt;BR /&gt;
M             L                2011-02-28        4.79  = 4.79          &lt;BR /&gt;
M             L                2011-03-01        4.69  = 4.69          &lt;BR /&gt;
M             L                2011-03-02        4.89  = 4.69         &lt;BR /&gt;
           &lt;BR /&gt;
Thanks</description>
    <pubDate>Tue, 12 Apr 2011 18:59:43 GMT</pubDate>
    <dc:creator>wildhogs</dc:creator>
    <dc:date>2011-04-12T18:59:43Z</dc:date>
    <item>
      <title>selecting Min Rate within a group of records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selecting-Min-Rate-within-a-group-of-records/m-p/48650#M10054</link>
      <description>For this example I need to check each row in the following table and determine the minimum rate for each group of records for the past 2 days. &lt;BR /&gt;
&lt;BR /&gt;
In reality I need to check the past 36 days...&lt;BR /&gt;
&lt;BR /&gt;
Product   Treatment    date                  rate&lt;BR /&gt;
================================&lt;BR /&gt;
M             H               2011-02-28        2.29  = 2.29          &lt;BR /&gt;
M             H               2011-03-01        2.19  = 2.19          &lt;BR /&gt;
M             H               2011-03-02        2.09  = 2.09                &lt;BR /&gt;
&lt;BR /&gt;
M             M               2011-02-28        3.39  = 3.39            &lt;BR /&gt;
M             M               2011-03-01        3.49  = 3.39          &lt;BR /&gt;
M             M               2011-03-02        3.59  = 3.39          &lt;BR /&gt;
&lt;BR /&gt;
M             L                2011-02-28        4.79  = 4.79          &lt;BR /&gt;
M             L                2011-03-01        4.69  = 4.69          &lt;BR /&gt;
M             L                2011-03-02        4.89  = 4.69         &lt;BR /&gt;
           &lt;BR /&gt;
Thanks</description>
      <pubDate>Tue, 12 Apr 2011 18:59:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selecting-Min-Rate-within-a-group-of-records/m-p/48650#M10054</guid>
      <dc:creator>wildhogs</dc:creator>
      <dc:date>2011-04-12T18:59:43Z</dc:date>
    </item>
    <item>
      <title>Re: selecting Min Rate within a group of records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selecting-Min-Rate-within-a-group-of-records/m-p/48651#M10055</link>
      <description>Opps.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data temp;&lt;BR /&gt;
input Product $ Treatment $ Date : yymmdd12. Rate ;&lt;BR /&gt;
format date yymmdd10.;&lt;BR /&gt;
datalines;&lt;BR /&gt;
Mortgage High 2011-02-28 2.29 &lt;BR /&gt;
Mortgage High 2011-03-01 2.19 &lt;BR /&gt;
Mortgage High 2011-03-02 2.09 &lt;BR /&gt;
Mortgage Med 2011-02-28 3.29 &lt;BR /&gt;
Mortgage Med 2011-03-01 3.19 &lt;BR /&gt;
Mortgage Med 2011-03-02 3.09 &lt;BR /&gt;
Mortgage Low 2011-02-28 4.29 &lt;BR /&gt;
Mortgage Low 2011-03-01 4.19 &lt;BR /&gt;
Mortgage Low 2011-03-02 4.09 &lt;BR /&gt;
Mortgage Low 2011-03-03 4.99 &lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
proc sql;&lt;BR /&gt;
create table min_rate as&lt;BR /&gt;
 select a.*,min(b.rate) as min_rate&lt;BR /&gt;
  from temp as a,temp as b&lt;BR /&gt;
   where a.product = b.product and a.treatment = b.treatment&lt;BR /&gt;
         and b.date between a.date-1 and a.date &lt;BR /&gt;
     group by a.product,a.treatment,a.date,a.rate&lt;BR /&gt;
   ;&lt;BR /&gt;
quit;[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp

Message was edited by: Ksharp</description>
      <pubDate>Wed, 13 Apr 2011 03:51:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selecting-Min-Rate-within-a-group-of-records/m-p/48651#M10055</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-04-13T03:51:43Z</dc:date>
    </item>
  </channel>
</rss>

