<?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 Find second max value in array and return column name in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Find-second-max-value-in-array-and-return-column-name/m-p/298963#M60366</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What i am trying to accomplish is the following , i have an array with 4 variables containing values lest say 1, 2 ,5, 6 etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am able to get the max value of the array and have the column name returned but I am stuck on how I can do the same procedure for the next largest value, any ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards and thank you in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my script up till now&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA WANT;&lt;BR /&gt;SET HAVE;&lt;/P&gt;&lt;P&gt;ARRAY COL(*) col1&amp;nbsp;--col4;&lt;/P&gt;&lt;P&gt;INDEX_OF_MAX=WHICHN(MAX(OF COL(*)),OF COL(*));&lt;BR /&gt;VALUE_1=VNAME(COL(INDEX_OF_MAX));&lt;BR /&gt;RUN;&lt;/P&gt;</description>
    <pubDate>Fri, 16 Sep 2016 15:40:46 GMT</pubDate>
    <dc:creator>ConsAth</dc:creator>
    <dc:date>2016-09-16T15:40:46Z</dc:date>
    <item>
      <title>Find second max value in array and return column name</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Find-second-max-value-in-array-and-return-column-name/m-p/298963#M60366</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What i am trying to accomplish is the following , i have an array with 4 variables containing values lest say 1, 2 ,5, 6 etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am able to get the max value of the array and have the column name returned but I am stuck on how I can do the same procedure for the next largest value, any ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards and thank you in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my script up till now&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA WANT;&lt;BR /&gt;SET HAVE;&lt;/P&gt;&lt;P&gt;ARRAY COL(*) col1&amp;nbsp;--col4;&lt;/P&gt;&lt;P&gt;INDEX_OF_MAX=WHICHN(MAX(OF COL(*)),OF COL(*));&lt;BR /&gt;VALUE_1=VNAME(COL(INDEX_OF_MAX));&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2016 15:40:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Find-second-max-value-in-array-and-return-column-name/m-p/298963#M60366</guid>
      <dc:creator>ConsAth</dc:creator>
      <dc:date>2016-09-16T15:40:46Z</dc:date>
    </item>
    <item>
      <title>Re: Find second max value in array and return column name</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Find-second-max-value-in-array-and-return-column-name/m-p/298985#M60369</link>
      <description>&lt;P&gt;The function LARGEST is what you are looking for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second = Largest(2, of col(*));&lt;/P&gt;
&lt;P&gt;Third = Largest(3, of col(*));&lt;/P&gt;
&lt;P&gt;and so on. the 2 or 3 could be a variable as well.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2016 17:00:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Find-second-max-value-in-array-and-return-column-name/m-p/298985#M60369</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-09-16T17:00:33Z</dc:date>
    </item>
  </channel>
</rss>

