<?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: Return variable with Maximum Value in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Return-variable-with-Maximum-Value/m-p/26726#M6129</link>
    <description>Hello Ddeb,&lt;BR /&gt;
&lt;BR /&gt;
You can add to you datastep writing MAX_SALES into a macro variable like this:&lt;BR /&gt;
&lt;BR /&gt;
call SUMPUTX('Max',MAX_SALES);&lt;BR /&gt;
&lt;BR /&gt;
and then in a separate datastep:&lt;BR /&gt;
&lt;BR /&gt;
array{*} S sales:;&lt;BR /&gt;
do i=1 to hbound{S};&lt;BR /&gt;
   if s[i]=&amp;amp;Max then Max_month=i;&lt;BR /&gt;
end;&lt;BR /&gt;
&lt;BR /&gt;
get month number for maximum sales.&lt;BR /&gt;
&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
    <pubDate>Fri, 11 Mar 2011 16:19:48 GMT</pubDate>
    <dc:creator>SPR</dc:creator>
    <dc:date>2011-03-11T16:19:48Z</dc:date>
    <item>
      <title>Return variable with Maximum Value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Return-variable-with-Maximum-Value/m-p/26724#M6127</link>
      <description>I have data of the form:&lt;BR /&gt;
&lt;BR /&gt;
ID      Sales_JAN    Sales_FEB    Sales_MAR    etc....&lt;BR /&gt;
&lt;BR /&gt;
I know that I can get the maximum sales value for each ID as:&lt;BR /&gt;
MAX_SALES = MAX (OF SALES:);&lt;BR /&gt;
&lt;BR /&gt;
I also want to know which month the maximum sales happened in (the variable name which corresponds to the maximum value).  I cannot figure out how to do this efficiently.  I'm sure SAS has a way of doing this (it has a way of doing most things).  If JAN and FEB had the same sales and they were the MAX value, how are ties handled?</description>
      <pubDate>Thu, 10 Mar 2011 20:43:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Return-variable-with-Maximum-Value/m-p/26724#M6127</guid>
      <dc:creator>ddeb</dc:creator>
      <dc:date>2011-03-10T20:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: Return variable with Maximum Value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Return-variable-with-Maximum-Value/m-p/26725#M6128</link>
      <description>WHICHN Function&lt;BR /&gt;
&lt;BR /&gt;
--------------------------------------------------------------------------------&lt;BR /&gt;
&lt;BR /&gt;
Searches for a numeric value that is equal to the first argument, and returns the index of the first matching value.</description>
      <pubDate>Thu, 10 Mar 2011 21:26:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Return-variable-with-Maximum-Value/m-p/26725#M6128</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-03-10T21:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: Return variable with Maximum Value</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Return-variable-with-Maximum-Value/m-p/26726#M6129</link>
      <description>Hello Ddeb,&lt;BR /&gt;
&lt;BR /&gt;
You can add to you datastep writing MAX_SALES into a macro variable like this:&lt;BR /&gt;
&lt;BR /&gt;
call SUMPUTX('Max',MAX_SALES);&lt;BR /&gt;
&lt;BR /&gt;
and then in a separate datastep:&lt;BR /&gt;
&lt;BR /&gt;
array{*} S sales:;&lt;BR /&gt;
do i=1 to hbound{S};&lt;BR /&gt;
   if s[i]=&amp;amp;Max then Max_month=i;&lt;BR /&gt;
end;&lt;BR /&gt;
&lt;BR /&gt;
get month number for maximum sales.&lt;BR /&gt;
&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Fri, 11 Mar 2011 16:19:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Return-variable-with-Maximum-Value/m-p/26726#M6129</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-03-11T16:19:48Z</dc:date>
    </item>
  </channel>
</rss>

