<?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: Keeping Max Value and Changing Other Values in Subgroup Contingent Upon Logic in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Keeping-Max-Value-and-Changing-Other-Values-in-Subgroup/m-p/246262#M56232</link>
    <description>&lt;P&gt;Then kindly mark the question as answered.&lt;/P&gt;</description>
    <pubDate>Wed, 27 Jan 2016 01:11:02 GMT</pubDate>
    <dc:creator>mohamed_zaki</dc:creator>
    <dc:date>2016-01-27T01:11:02Z</dc:date>
    <item>
      <title>Keeping Max Value and Changing Other Values in Subgroup Contingent Upon Logic</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keeping-Max-Value-and-Changing-Other-Values-in-Subgroup/m-p/246254#M56225</link>
      <description>&lt;P&gt;In words here are the rules I want to implement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If Flag = N then WANT = HAVE&lt;/P&gt;
&lt;P&gt;If Flag = Y and HAVE value is max among observations with same ID, then WANT=HAVE&lt;/P&gt;
&lt;P&gt;If Flag = Y and above rule is false, then WANT=.5*HAVE&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there's an instance where two values for an ID are max (and Flag=Y), then arbitrarily WANT = HAVE for one and WANT = .5*HAVE for the other. (this is shown for ID b below)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1624i6CA13C9CBEC5E4CD/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="stack.png" title="stack.png" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2016 00:28:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keeping-Max-Value-and-Changing-Other-Values-in-Subgroup/m-p/246254#M56225</guid>
      <dc:creator>acemanhattan</dc:creator>
      <dc:date>2016-01-27T00:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping Max Value and Changing Other Values in Subgroup Contingent Upon Logic</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keeping-Max-Value-and-Changing-Other-Values-in-Subgroup/m-p/246257#M56228</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
by ID flag have;
run;

data want;
set have;
by ID flag have;
if Flag = 'N' then want=have;
else if flag ='Y' and last.flag then want=have;
else want =.5*have;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Jan 2016 00:52:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keeping-Max-Value-and-Changing-Other-Values-in-Subgroup/m-p/246257#M56228</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2016-01-27T00:52:54Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping Max Value and Changing Other Values in Subgroup Contingent Upon Logic</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keeping-Max-Value-and-Changing-Other-Values-in-Subgroup/m-p/246261#M56231</link>
      <description>This worked superbly.  Thanks.</description>
      <pubDate>Wed, 27 Jan 2016 01:09:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keeping-Max-Value-and-Changing-Other-Values-in-Subgroup/m-p/246261#M56231</guid>
      <dc:creator>acemanhattan</dc:creator>
      <dc:date>2016-01-27T01:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping Max Value and Changing Other Values in Subgroup Contingent Upon Logic</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keeping-Max-Value-and-Changing-Other-Values-in-Subgroup/m-p/246262#M56232</link>
      <description>&lt;P&gt;Then kindly mark the question as answered.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2016 01:11:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keeping-Max-Value-and-Changing-Other-Values-in-Subgroup/m-p/246262#M56232</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2016-01-27T01:11:02Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping Max Value and Changing Other Values in Subgroup Contingent Upon Logic</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keeping-Max-Value-and-Changing-Other-Values-in-Subgroup/m-p/246264#M56233</link>
      <description>&lt;P&gt;You need clarify something more .&lt;/P&gt;
&lt;P&gt;What&amp;nbsp;&lt;SPAN&gt;If there's an instance where &lt;STRONG&gt;THREE&amp;nbsp;&lt;/STRONG&gt;values for an ID are max (and Flag=Y), What you are going to do ?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;And Don't post it as picture, post it as TEXT . No one would like to type it for you and would ignore your quesiton.&lt;/SPAN&gt;&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;
input id $ flag $ have ;
cards;
a y 8437
a y 4533
a n 6814
b n 5322
b y 8031
b y 8031
;
run;
data want;
 do until(last.id);
  set have;
  by id;
  max=max(max,have);
 end;
 do until(last.id);
  set have;
  by id;
  if flag='n' then want=have;
  if flag='y' and have ne max then want=.5*have;
  if flag='y' and have=max then do;
   if found then want=.5*have;
    else do;want=have;found=1;end;
  end; 
  output;
 end;
 drop max;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Jan 2016 01:12:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keeping-Max-Value-and-Changing-Other-Values-in-Subgroup/m-p/246264#M56233</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-01-27T01:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping Max Value and Changing Other Values in Subgroup Contingent Upon Logic</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keeping-Max-Value-and-Changing-Other-Values-in-Subgroup/m-p/246341#M56236</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;, thanks for the feedback and the tip about text vs image.  &lt;BR /&gt;&lt;BR /&gt;It looks to me like &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/49185"&gt;@mohamed_zaki&lt;/a&gt;'s reply addresses the issue of if three values are max and flag = 'Y'.  The data would be sorted so that the HAVE column ascends so that &lt;BR /&gt;&lt;BR /&gt;else if flag ='Y' and last.flag then want=have;&lt;BR /&gt;else want =.5*have;&lt;BR /&gt;&lt;BR /&gt;causes only the last instance to set want=have, whereas the previous instances would be set to want=.5*have.  &lt;BR /&gt;&lt;BR /&gt;Am I incorrect?</description>
      <pubDate>Wed, 27 Jan 2016 14:05:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keeping-Max-Value-and-Changing-Other-Values-in-Subgroup/m-p/246341#M56236</guid>
      <dc:creator>acemanhattan</dc:creator>
      <dc:date>2016-01-27T14:05:52Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping Max Value and Changing Other Values in Subgroup Contingent Upon Logic</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keeping-Max-Value-and-Changing-Other-Values-in-Subgroup/m-p/246510#M56240</link>
      <description>&lt;P&gt;It is hard to say something , it is all depend on what you want.&lt;/P&gt;
&lt;P&gt;And There looks like some problem in his code :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;input id $ flag $ have ;&lt;BR /&gt;cards;&lt;BR /&gt;a y 8437&lt;BR /&gt;a y 4533&lt;BR /&gt;a n 6814&lt;BR /&gt;&lt;STRONG&gt;b n 9322&lt;/STRONG&gt;&lt;BR /&gt;b y 8031&lt;BR /&gt;b y 8031&lt;BR /&gt;;&lt;BR /&gt;proc sort data=have;&lt;BR /&gt;by ID flag have;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;by ID flag have;&lt;BR /&gt;if Flag = 'n' then want=have;&lt;BR /&gt;else if flag ='y' and last.flag then want=have;&lt;BR /&gt;else want =.5*have;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2016 01:21:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keeping-Max-Value-and-Changing-Other-Values-in-Subgroup/m-p/246510#M56240</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-01-28T01:21:34Z</dc:date>
    </item>
  </channel>
</rss>

