<?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: maximum value in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/maximum-value/m-p/1147#M534</link>
    <description>Olivier!&lt;BR /&gt;
&lt;BR /&gt;
Merci!  thank you so much!</description>
    <pubDate>Thu, 27 Jul 2006 13:16:19 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2006-07-27T13:16:19Z</dc:date>
    <item>
      <title>maximum value</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/maximum-value/m-p/1142#M529</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
Here's my problem: I have 10 variables (columns) and I would like to create an other variable which would consist of the highest value from the preceding 10 variables.  The thing is, I don't actually want the  value, but the variable's name corresponding to that maximum value. Could you help me?&lt;BR /&gt;
&lt;BR /&gt;
Many thanks!</description>
      <pubDate>Wed, 26 Jul 2006 13:23:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/maximum-value/m-p/1142#M529</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2006-07-26T13:23:44Z</dc:date>
    </item>
    <item>
      <title>Re: maximum value</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/maximum-value/m-p/1143#M530</link>
      <description>A suggestion:&lt;BR /&gt;
1. Find the maximum value of all 10 variables using MAX() function.&lt;BR /&gt;
2. Create an array of all 10 variables.&lt;BR /&gt;
3. Compare the maximum value to each variable in the array in a DO..END loop, and note which variable has the same value as the maximum.&lt;BR /&gt;
&lt;BR /&gt;
A question:&lt;BR /&gt;
If 2 or more variables have the same maximum value, do you need to know all their names?&lt;BR /&gt;
&lt;BR /&gt;
.......Phil</description>
      <pubDate>Wed, 26 Jul 2006 13:36:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/maximum-value/m-p/1143#M530</guid>
      <dc:creator>prholland</dc:creator>
      <dc:date>2006-07-26T13:36:30Z</dc:date>
    </item>
    <item>
      <title>Re: maximum value</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/maximum-value/m-p/1144#M531</link>
      <description>thanks!&lt;BR /&gt;
&lt;BR /&gt;
To your question: no, I am deleting those data (if 2 have the same and the largest value)&lt;BR /&gt;
&lt;BR /&gt;
another question: is there a command to find the 2nd largest value?</description>
      <pubDate>Wed, 26 Jul 2006 14:30:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/maximum-value/m-p/1144#M531</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2006-07-26T14:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: maximum value</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/maximum-value/m-p/1145#M532</link>
      <description>I'm not aware of a "2nd largest value" function.&lt;BR /&gt;
&lt;BR /&gt;
As a workaround you could repeat my previous code, but, knowing which variable held the maximum value, exclude that one from the array and find the maximum of the remaining 9.  Alternatively assign a very small, or large negative, value to the "maximum" variable, then repeat the code asis.&lt;BR /&gt;
&lt;BR /&gt;
.......Phil</description>
      <pubDate>Wed, 26 Jul 2006 14:46:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/maximum-value/m-p/1145#M532</guid>
      <dc:creator>prholland</dc:creator>
      <dc:date>2006-07-26T14:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: maximum value</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/maximum-value/m-p/1146#M533</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
there is a LARGEST(k, variable_list) beginning with SAS9 ; k equals 1 if you want the maximum, k=2 will give you the second greatest value, and so on.&lt;BR /&gt;
&lt;BR /&gt;
For your problem of recording the variables names according to their order, is the following example of any help ?&lt;BR /&gt;
&lt;BR /&gt;
DATA work.test ;&lt;BR /&gt;
	INPUT x1-x5 ;&lt;BR /&gt;
CARDS ;&lt;BR /&gt;
45 454 484 21 2&lt;BR /&gt;
2121 5156 5645 451 5451&lt;BR /&gt;
5151 2121 21 313 26&lt;BR /&gt;
55 64 65 1 231&lt;BR /&gt;
;&lt;BR /&gt;
RUN ;&lt;BR /&gt;
DATA work.whos_who (DROP = nth: j) ;&lt;BR /&gt;
	SET work.test ;&lt;BR /&gt;
	ARRAY myXs _NUMERIC_ ;&lt;BR /&gt;
	ARRAY theirNames $ name1-name5 ;&lt;BR /&gt;
	DO nth = 1 TO DIM(myXs) ;&lt;BR /&gt;
		nth_biggest = LARGEST(nth, OF x1-x5) ;&lt;BR /&gt;
		DO j = 1 TO DIM(myXs) ;&lt;BR /&gt;
			IF nth_biggest = myXs(j) THEN theirNames(nth) = VNAME(myXs(j)) ;&lt;BR /&gt;
		END ;&lt;BR /&gt;
	END ;&lt;BR /&gt;
RUN ;</description>
      <pubDate>Thu, 27 Jul 2006 09:18:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/maximum-value/m-p/1146#M533</guid>
      <dc:creator>Olivier</dc:creator>
      <dc:date>2006-07-27T09:18:48Z</dc:date>
    </item>
    <item>
      <title>Re: maximum value</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/maximum-value/m-p/1147#M534</link>
      <description>Olivier!&lt;BR /&gt;
&lt;BR /&gt;
Merci!  thank you so much!</description>
      <pubDate>Thu, 27 Jul 2006 13:16:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/maximum-value/m-p/1147#M534</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2006-07-27T13:16:19Z</dc:date>
    </item>
    <item>
      <title>Re: maximum value</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/maximum-value/m-p/1148#M535</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
Why not putting your variables in an array, sort the array and automatically you will have an easy access to the highest value, second highest, lowest, etc ...&lt;BR /&gt;
There is an experimental array sorting function in SAS 9, try the example below.&lt;BR /&gt;
&lt;BR /&gt;
Good luck,&lt;BR /&gt;
Otto.&lt;BR /&gt;
&lt;BR /&gt;
data t;&lt;BR /&gt;
 infile cards;&lt;BR /&gt;
 input var bar nar kar lar ; * just some variable names ;&lt;BR /&gt;
cards;&lt;BR /&gt;
1 8 2 77 13&lt;BR /&gt;
5 3 1 4 6&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data tt;&lt;BR /&gt;
 set t;&lt;BR /&gt;
 array v &lt;LI&gt; var bar nar kar lar ;&lt;BR /&gt;
 call sortn (of v&lt;/LI&gt;&lt;LI&gt;); &lt;BR /&gt;
run;&lt;/LI&gt;</description>
      <pubDate>Thu, 27 Jul 2006 14:49:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/maximum-value/m-p/1148#M535</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2006-07-27T14:49:56Z</dc:date>
    </item>
  </channel>
</rss>

