<?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 variable name of maximium values in case of tie using array in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-variable-name-of-maximium-values-in-case-of-tie-using-array/m-p/273200#M54419</link>
    <description>&lt;P&gt;Hello Everyone&lt;/P&gt;&lt;P&gt;I need to find varaible name of maximium value even if there is a tie using array.&lt;/P&gt;&lt;P&gt;Sample dataset&lt;/P&gt;&lt;P&gt;Data test;&lt;/P&gt;&lt;P&gt;input TT TS TM JAG TL;&lt;/P&gt;&lt;P&gt;DATALINES;&lt;/P&gt;&lt;P&gt;450 789 850 789 745&lt;/P&gt;&lt;P&gt;145 523 854 125 452&lt;/P&gt;&lt;P&gt;356 896 785 452&amp;nbsp; 896&lt;/P&gt;&lt;P&gt;523 589 846 475 145&lt;/P&gt;&lt;P&gt;632 521 452 785 452&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;now i want to create a variable which will store the variable name of maxmium value&lt;/P&gt;&lt;P&gt;for eg&lt;/P&gt;&lt;P&gt;output dataset&lt;/P&gt;&lt;P&gt;TT&amp;nbsp; TS&amp;nbsp; TM&amp;nbsp; JAG&amp;nbsp; TL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; max&lt;/P&gt;&lt;P&gt;850 789 850 789 745&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;TT/TM&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;145 523 254 125 452&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TS&lt;/P&gt;&lt;P&gt;356 896 896 452&amp;nbsp; 896&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;&lt;FONT color="#333333"&gt; TS/TM/TL&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;523 589 846 475 145&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TM&lt;/P&gt;&lt;P&gt;785&amp;nbsp; 521 452 785 452&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;STRONG&gt; TT/JAG&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically i wantname of variable for all the maximium values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please use concept of ARRAY only&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks~&lt;/P&gt;</description>
    <pubDate>Thu, 26 May 2016 05:23:40 GMT</pubDate>
    <dc:creator>sasabd</dc:creator>
    <dc:date>2016-05-26T05:23:40Z</dc:date>
    <item>
      <title>Find variable name of maximium values in case of tie using array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-variable-name-of-maximium-values-in-case-of-tie-using-array/m-p/273200#M54419</link>
      <description>&lt;P&gt;Hello Everyone&lt;/P&gt;&lt;P&gt;I need to find varaible name of maximium value even if there is a tie using array.&lt;/P&gt;&lt;P&gt;Sample dataset&lt;/P&gt;&lt;P&gt;Data test;&lt;/P&gt;&lt;P&gt;input TT TS TM JAG TL;&lt;/P&gt;&lt;P&gt;DATALINES;&lt;/P&gt;&lt;P&gt;450 789 850 789 745&lt;/P&gt;&lt;P&gt;145 523 854 125 452&lt;/P&gt;&lt;P&gt;356 896 785 452&amp;nbsp; 896&lt;/P&gt;&lt;P&gt;523 589 846 475 145&lt;/P&gt;&lt;P&gt;632 521 452 785 452&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;now i want to create a variable which will store the variable name of maxmium value&lt;/P&gt;&lt;P&gt;for eg&lt;/P&gt;&lt;P&gt;output dataset&lt;/P&gt;&lt;P&gt;TT&amp;nbsp; TS&amp;nbsp; TM&amp;nbsp; JAG&amp;nbsp; TL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; max&lt;/P&gt;&lt;P&gt;850 789 850 789 745&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;TT/TM&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;145 523 254 125 452&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TS&lt;/P&gt;&lt;P&gt;356 896 896 452&amp;nbsp; 896&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;&lt;FONT color="#333333"&gt; TS/TM/TL&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;523 589 846 475 145&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TM&lt;/P&gt;&lt;P&gt;785&amp;nbsp; 521 452 785 452&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;STRONG&gt; TT/JAG&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically i wantname of variable for all the maximium values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please use concept of ARRAY only&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks~&lt;/P&gt;</description>
      <pubDate>Thu, 26 May 2016 05:23:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-variable-name-of-maximium-values-in-case-of-tie-using-array/m-p/273200#M54419</guid>
      <dc:creator>sasabd</dc:creator>
      <dc:date>2016-05-26T05:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: Find variable name of maximium values in case of tie using array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-variable-name-of-maximium-values-in-case-of-tie-using-array/m-p/273203#M54420</link>
      <description>&lt;P&gt;Here is one way. NOTE:P the length assignment of the names variable is very important. Make it too short and your logic may work but the results would be truncated.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data test;
   input TT TS TM JAG TL;
   array v   TT TS TM JAG TL;
   /* if you want one variable to hold ALL of the potential names
   it should be n*32 + (n-1) to hold the names and separaters*/
   length names $ 164 name $ 32;
   m = max(of v(*));
   /* what to do if all values are missing*/
   if m ne . then do i= 1 to dim(v);
      if m = v[i] then do;
         name= vname(v[i]);
         names = catx('/',names,name);
      end; 
   end;
   drop i m name;

DATALINES;
450 789 850 789 745
145 523 854 125 452
356 896 785 452  896
523 589 846 475 145
632 521 452 785 452
1   1   1   1   1
.   .   .   .   .
;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 May 2016 06:07:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-variable-name-of-maximium-values-in-case-of-tie-using-array/m-p/273203#M54420</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-05-26T06:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: Find variable name of maximium values in case of tie using array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-variable-name-of-maximium-values-in-case-of-tie-using-array/m-p/273244#M54425</link>
      <description>&lt;P&gt;A small update to use the do over shrinks the code a bit. &amp;nbsp;Doesn't of course answer the all missing question:&lt;/P&gt;
&lt;PRE&gt;data test;
  length names $200;
  input TT TS TM JAG TL;
  array v tt--tl;
  do over v;
    names=catx('/',names,ifc(v=max(of v{*}),vname(v),""));
  end; 
datalines;
450 789 850 789 745
145 523 854 125 452
356 896 785 452  896
523 589 846 475 145
632 521 452 785 452
1   1   1   1   1
.   .   .   .   .
;
run;&lt;/PRE&gt;
&lt;P&gt;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 May 2016 12:54:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-variable-name-of-maximium-values-in-case-of-tie-using-array/m-p/273244#M54425</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-05-26T12:54:52Z</dc:date>
    </item>
  </channel>
</rss>

