<?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: Get values of minimum date with a range in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Get-values-of-minimum-date-with-a-range/m-p/717816#M222049</link>
    <description>ID - DATE - AMT- CITY- CODE&lt;BR /&gt;1-07SEP2020-10000-LONDON-PPS&lt;BR /&gt;1-11DEC2020-50000-BELARUS-PPK&lt;BR /&gt;2-06DEC2020-40000-COLOMBO-PPS&lt;BR /&gt;2-28JAN2021-30000-MUMBAI-PPL&lt;BR /&gt;2-02DEC2020-20000-MUNICH-PPS&lt;BR /&gt;&lt;BR /&gt;I need to get this assuming my filter month is DEC 2020&lt;BR /&gt;ID-AMT:&lt;BR /&gt;1-0 (since minimum date for this customer is September)&lt;BR /&gt;2-20000</description>
    <pubDate>Tue, 09 Feb 2021 09:09:33 GMT</pubDate>
    <dc:creator>udupa_13</dc:creator>
    <dc:date>2021-02-09T09:09:33Z</dc:date>
    <item>
      <title>Get values of minimum date with a range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-values-of-minimum-date-with-a-range/m-p/717808#M222044</link>
      <description>&lt;P&gt;Data comprises of several columns including customer ID but need to pull data of only from the row with minimum date from (DATEVAL) for each customer, however this minimum date has to be within a range eg: within Dec'20 month. And finally sum the amount(AMT) of that customer for that month only.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 08:54:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-values-of-minimum-date-with-a-range/m-p/717808#M222044</guid>
      <dc:creator>udupa_13</dc:creator>
      <dc:date>2021-02-09T08:54:00Z</dc:date>
    </item>
    <item>
      <title>Re: Get values of minimum date with a range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-values-of-minimum-date-with-a-range/m-p/717814#M222047</link>
      <description>&lt;P&gt;Could you please provide a small set of your sample data, it is quite ambiguous to me regarding your request?&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 09:01:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-values-of-minimum-date-with-a-range/m-p/717814#M222047</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-02-09T09:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: Get values of minimum date with a range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-values-of-minimum-date-with-a-range/m-p/717815#M222048</link>
      <description>&lt;P&gt;The requirement "need to pull data of only from the row with minimum date" seems to contradict "sum the amount(AMT) of that customer for that month only", so please post data in usable form and what you expect as result.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 09:08:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-values-of-minimum-date-with-a-range/m-p/717815#M222048</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-02-09T09:08:40Z</dc:date>
    </item>
    <item>
      <title>Re: Get values of minimum date with a range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-values-of-minimum-date-with-a-range/m-p/717816#M222049</link>
      <description>ID - DATE - AMT- CITY- CODE&lt;BR /&gt;1-07SEP2020-10000-LONDON-PPS&lt;BR /&gt;1-11DEC2020-50000-BELARUS-PPK&lt;BR /&gt;2-06DEC2020-40000-COLOMBO-PPS&lt;BR /&gt;2-28JAN2021-30000-MUMBAI-PPL&lt;BR /&gt;2-02DEC2020-20000-MUNICH-PPS&lt;BR /&gt;&lt;BR /&gt;I need to get this assuming my filter month is DEC 2020&lt;BR /&gt;ID-AMT:&lt;BR /&gt;1-0 (since minimum date for this customer is September)&lt;BR /&gt;2-20000</description>
      <pubDate>Tue, 09 Feb 2021 09:09:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-values-of-minimum-date-with-a-range/m-p/717816#M222049</guid>
      <dc:creator>udupa_13</dc:creator>
      <dc:date>2021-02-09T09:09:33Z</dc:date>
    </item>
    <item>
      <title>Re: Get values of minimum date with a range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-values-of-minimum-date-with-a-range/m-p/717819#M222052</link>
      <description>Sorry for the confusion.&lt;BR /&gt;Provided a scenario here: &lt;A href="https://communities.sas.com/t5/SAS-Programming/Get-values-of-minimum-date-with-a-range/m-p/717816#M222049" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Get-values-of-minimum-date-with-a-range/m-p/717816#M222049&lt;/A&gt;</description>
      <pubDate>Tue, 09 Feb 2021 09:13:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-values-of-minimum-date-with-a-range/m-p/717819#M222052</guid>
      <dc:creator>udupa_13</dc:creator>
      <dc:date>2021-02-09T09:13:15Z</dc:date>
    </item>
    <item>
      <title>Re: Get values of minimum date with a range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-values-of-minimum-date-with-a-range/m-p/717824#M222055</link>
      <description>&lt;P&gt;Does next code fits you requirements? If not - please explain what is the issue.&lt;/P&gt;
&lt;P&gt;(coed was edited to fix bugs )&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; 
  length city $12 month $7;
  input ID  DATE :date9. AMT  CITY $ CODE $;
  month = put(date, yymms7.);
cards;
1 07SEP2020 10000 LONDON  PPS
1 11DEC2020 50000 BELARUS PPK
2 06DEC2020 40000 COLOMBO PPS
2 28JAN2021 30000 MUMBAI  PPL
2 02DEC2020 20000 MUNICH  PPS
; run;

/* sort and select 1st month of ID */
proc sort data=have; by ID date; run;
data to_select;
 set have;
  by ID;
     if first.ID then output; /* or select by required month "yyyy/mm" */
     keep ID month;
run;
/* select data to deal with and sum amount */
proc sql;
   select a.ID, 
          sum(amt) as total
   from have as a 
   right join to_select as b 
   on a.ID=b.ID and a.month = b.month
   group by a.ID;
quit;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Feb 2021 09:50:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-values-of-minimum-date-with-a-range/m-p/717824#M222055</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-02-09T09:50:04Z</dc:date>
    </item>
    <item>
      <title>Re: Get values of minimum date with a range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-values-of-minimum-date-with-a-range/m-p/717830#M222058</link>
      <description>Data is already present in the server, so I need only the query to get the desired output without making a new dataset</description>
      <pubDate>Tue, 09 Feb 2021 10:13:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-values-of-minimum-date-with-a-range/m-p/717830#M222058</guid>
      <dc:creator>udupa_13</dc:creator>
      <dc:date>2021-02-09T10:13:47Z</dc:date>
    </item>
    <item>
      <title>Re: Get values of minimum date with a range</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-values-of-minimum-date-with-a-range/m-p/717831#M222059</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/317181"&gt;@udupa_13&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Data is already present in the server, so I need only the query to get the desired output without making a new dataset&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The step creating the dataset "have" is only part of the code, because you failed to provide the data in usable form.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 10:23:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-values-of-minimum-date-with-a-range/m-p/717831#M222059</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-02-09T10:23:35Z</dc:date>
    </item>
  </channel>
</rss>

