<?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: max spend in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/max-spend/m-p/245879#M45929</link>
    <description>&lt;P&gt;Sort by id, purchase date and amount.&lt;/P&gt;
&lt;P&gt;Then use last.id in a data step to get the most recent date, and from that the highest amount.&lt;/P&gt;</description>
    <pubDate>Mon, 25 Jan 2016 14:18:56 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-01-25T14:18:56Z</dc:date>
    <item>
      <title>max spend</title>
      <link>https://communities.sas.com/t5/SAS-Programming/max-spend/m-p/245877#M45927</link>
      <description>&lt;P&gt;Hello all&lt;/P&gt;&lt;P&gt;I am sure this question is out there, I just cannot find it!&lt;/P&gt;&lt;P&gt;I have member ids that have multiple purchase dates. So I took the most recent date. Well, some member ids have multiple purchases in one day.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a code to take the max spend for that mem id so I can get rid of the second date with the smaller amount?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mary&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2016 14:08:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/max-spend/m-p/245877#M45927</guid>
      <dc:creator>wilsonm3e</dc:creator>
      <dc:date>2016-01-25T14:08:54Z</dc:date>
    </item>
    <item>
      <title>Re: max spend</title>
      <link>https://communities.sas.com/t5/SAS-Programming/max-spend/m-p/245878#M45928</link>
      <description>&lt;P&gt;Can not you give example data? And the desired output?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2016 14:13:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/max-spend/m-p/245878#M45928</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2016-01-25T14:13:48Z</dc:date>
    </item>
    <item>
      <title>Re: max spend</title>
      <link>https://communities.sas.com/t5/SAS-Programming/max-spend/m-p/245879#M45929</link>
      <description>&lt;P&gt;Sort by id, purchase date and amount.&lt;/P&gt;
&lt;P&gt;Then use last.id in a data step to get the most recent date, and from that the highest amount.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2016 14:18:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/max-spend/m-p/245879#M45929</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-01-25T14:18:56Z</dc:date>
    </item>
    <item>
      <title>Re: max spend</title>
      <link>https://communities.sas.com/t5/SAS-Programming/max-spend/m-p/245880#M45930</link>
      <description>&lt;P&gt;do you have an example code of this ? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2016 14:24:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/max-spend/m-p/245880#M45930</guid>
      <dc:creator>wilsonm3e</dc:creator>
      <dc:date>2016-01-25T14:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: max spend</title>
      <link>https://communities.sas.com/t5/SAS-Programming/max-spend/m-p/245881#M45931</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have;
input ID Date Amount;
cards;
111 1 30
111 1 34
111 5 70
112 1 30
112 2 100
112 2 79
112 5 55
112 5 5
;
run;

proc sort data=have;
by ID date Amount;
run;

Data want ;
set have;
by ID  ;
if last.ID then output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;By this you will get the max spend in the most recent date for each mem id....&lt;/P&gt;
&lt;P&gt;Hope this what you want!&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2016 14:32:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/max-spend/m-p/245881#M45931</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2016-01-25T14:32:23Z</dc:date>
    </item>
    <item>
      <title>Re: max spend</title>
      <link>https://communities.sas.com/t5/SAS-Programming/max-spend/m-p/245884#M45932</link>
      <description>&lt;P&gt;What happens if you have multiple rows with the same max? &amp;nbsp;As an alternative this returns all records meeting the max() result:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table WANT as
  select  distinct *       /* Note take distinct out if you want all rows */
  from    HAVE
  group by ID
  having  AMOUNT=max(AMOUNT);
quit;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Jan 2016 14:41:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/max-spend/m-p/245884#M45932</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-01-25T14:41:56Z</dc:date>
    </item>
  </channel>
</rss>

