<?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: Issue in picking max amount form same date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Issue-in-picking-max-amount-form-same-date/m-p/477381#M122933</link>
    <description>&lt;P&gt;I am not sure i understand the logic you want to implement.&lt;/P&gt;
&lt;P&gt;From your description, i would guess the answer should be 300 and not 200.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    infile cards dlm=',' dsd;
    attrib Date format=date9. informat=ddmmyy8.;
    length name $10.;
    input ID Date name $ Amount Flag_first_name Flag_last_name;
cards;
12345,21032016,Bob,200,0,0
12345,21032016,Bob,300,0,0
12345,31122014,Bob,500,0,0
67890,31012012,John,100,0,0
67890,31012006,John,200,1,0
;
run;

proc sql;
    CREATE TABLE want AS
	SELECT * FROM (
        SELECT *
        FROM have
        WHERE strip(name)="Bob"
        GROUP BY name
        HAVING Date=max(Date)
	)
    GROUP BY Name
    HAVING Amount=max(Amount);
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 12 Jul 2018 10:14:26 GMT</pubDate>
    <dc:creator>gamotte</dc:creator>
    <dc:date>2018-07-12T10:14:26Z</dc:date>
    <item>
      <title>Issue in picking max amount form same date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-in-picking-max-amount-form-same-date/m-p/477361#M122929</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have been facing an issue with one logic, I have a list of dates and amounts, I need to pick the max amount from a same date based on a name.. attached is the example. kindly help in finding the mistake here.. Thank you..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jul 2018 07:52:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-in-picking-max-amount-form-same-date/m-p/477361#M122929</guid>
      <dc:creator>don21</dc:creator>
      <dc:date>2018-07-12T07:52:29Z</dc:date>
    </item>
    <item>
      <title>Re: Issue in picking max amount form same date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-in-picking-max-amount-form-same-date/m-p/477377#M122931</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    infile cards dlm=',' dsd;
    attrib Date format=date9. informat=ddmmyy8.;
    length name $10.;
    input ID Date name $ Amount Flag_first_name Flag_last_name;
cards;
12345,15082014,Bob,100,0,0
12345,20122016,Bob,200,0,0
12345,20122016,Bob,150,0,1
67890,31012012,John,100,0,0
67890,31012006,John,200,1,0
;
run;

proc sql;
    CREATE TABLE want AS
    SELECT *
    FROM have
    WHERE strip(name)="Bob"
    GROUP BY name, date
    HAVING Amount=max(Amount);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Jul 2018 09:36:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-in-picking-max-amount-form-same-date/m-p/477377#M122931</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-07-12T09:36:22Z</dc:date>
    </item>
    <item>
      <title>Re: Issue in picking max amount form same date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-in-picking-max-amount-form-same-date/m-p/477378#M122932</link>
      <description>&lt;P&gt;Hi Gamotte,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your below program will not work when there is a case like&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bob&amp;nbsp; 21032016&amp;nbsp; 200&lt;/P&gt;
&lt;P&gt;Bob&amp;nbsp; 21032016&amp;nbsp; 300&lt;/P&gt;
&lt;P&gt;Bob&amp;nbsp; 31122014&amp;nbsp; &amp;nbsp;500&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;in this case, your logic will return 500, but the answer I am looking for is 200,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;requirement is , when name=bob, date is latest (when latest data is same and has multiple records, then it should return max amount from those).. so the answer should be Bob&amp;nbsp; 21032016&amp;nbsp; 200&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;kindly advise.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jul 2018 09:51:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-in-picking-max-amount-form-same-date/m-p/477378#M122932</guid>
      <dc:creator>don21</dc:creator>
      <dc:date>2018-07-12T09:51:09Z</dc:date>
    </item>
    <item>
      <title>Re: Issue in picking max amount form same date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-in-picking-max-amount-form-same-date/m-p/477381#M122933</link>
      <description>&lt;P&gt;I am not sure i understand the logic you want to implement.&lt;/P&gt;
&lt;P&gt;From your description, i would guess the answer should be 300 and not 200.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    infile cards dlm=',' dsd;
    attrib Date format=date9. informat=ddmmyy8.;
    length name $10.;
    input ID Date name $ Amount Flag_first_name Flag_last_name;
cards;
12345,21032016,Bob,200,0,0
12345,21032016,Bob,300,0,0
12345,31122014,Bob,500,0,0
67890,31012012,John,100,0,0
67890,31012006,John,200,1,0
;
run;

proc sql;
    CREATE TABLE want AS
	SELECT * FROM (
        SELECT *
        FROM have
        WHERE strip(name)="Bob"
        GROUP BY name
        HAVING Date=max(Date)
	)
    GROUP BY Name
    HAVING Amount=max(Amount);
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Jul 2018 10:14:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-in-picking-max-amount-form-same-date/m-p/477381#M122933</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-07-12T10:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: Issue in picking max amount form same date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-in-picking-max-amount-form-same-date/m-p/477385#M122934</link>
      <description>&lt;P&gt;Stealing &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/30622"&gt;@gamotte&lt;/a&gt;'s example data:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    infile cards dlm=',' dsd;
    attrib Date format=date9. informat=ddmmyy8.;
    length name $10.;
    input ID Date name $ Amount Flag_first_name Flag_last_name;
cards;
12345,21032016,Bob,200,0,0
12345,21032016,Bob,300,0,0
12345,31122014,Bob,500,0,0
67890,31012012,John,100,0,0
67890,31012006,John,200,1,0
;
run;

proc sort data=have;
by id date amount;
run;

data want;
set have;
by id;
if last.id;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Jul 2018 10:31:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-in-picking-max-amount-form-same-date/m-p/477385#M122934</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-07-12T10:31:00Z</dc:date>
    </item>
  </channel>
</rss>

