<?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: Finding the max value in a group and assigning it in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-max-value-in-a-group-and-assigning-it/m-p/725355#M225291</link>
    <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table WANT as 
  select *, max(VAR) as MAX
  from TABLE
  group by ID;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;No need for a prior sort&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Mar 2021 07:14:38 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2021-03-11T07:14:38Z</dc:date>
    <item>
      <title>Finding the max value in a group and assigning it</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-max-value-in-a-group-and-assigning-it/m-p/725352#M225288</link>
      <description>&lt;P&gt;Hi, I'm new to SAS and I'm looking for a way to assign the maximum value of a group to the MaxInGroup column like below:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;U&gt;Group&lt;/U&gt; | &lt;U&gt;Value&lt;/U&gt; | &lt;U&gt;MaxInGroup&lt;/U&gt; (the resulting column)&lt;/P&gt;&lt;P&gt;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | 2&lt;/P&gt;&lt;P&gt;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | 2&lt;/P&gt;&lt;P&gt;B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | 4&lt;/P&gt;&lt;P&gt;B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | 4&lt;/P&gt;&lt;P&gt;B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | 4&lt;/P&gt;&lt;P&gt;C&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| 5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | 5&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I did is to use the proc sort statement to arrange the Group and Value column in descending order and if first.Group=1 and first.Value=1,&amp;nbsp;assign MaxInGroup =&amp;nbsp;Value. But I'm stuck at how to assign the same MaxInGroup value for the rest of the group.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Mar 2021 07:05:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-max-value-in-a-group-and-assigning-it/m-p/725352#M225288</guid>
      <dc:creator>jaycieleung</dc:creator>
      <dc:date>2021-03-11T07:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the max value in a group and assigning it</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-max-value-in-a-group-and-assigning-it/m-p/725355#M225291</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table WANT as 
  select *, max(VAR) as MAX
  from TABLE
  group by ID;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;No need for a prior sort&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Mar 2021 07:14:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-max-value-in-a-group-and-assigning-it/m-p/725355#M225291</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-03-11T07:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the max value in a group and assigning it</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-the-max-value-in-a-group-and-assigning-it/m-p/725363#M225295</link>
      <description>&lt;P&gt;That worked! thanks very much!&lt;/P&gt;</description>
      <pubDate>Thu, 11 Mar 2021 08:05:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-the-max-value-in-a-group-and-assigning-it/m-p/725363#M225295</guid>
      <dc:creator>jaycieleung</dc:creator>
      <dc:date>2021-03-11T08:05:41Z</dc:date>
    </item>
  </channel>
</rss>

