<?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 Max function and array in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Max-function-and-array/m-p/76906#M7625</link>
    <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
Is it possible to find the maximum entry in an array using max function?? The problem is that at each record, there is a different starting point in the array. e,g, &lt;BR /&gt;
&lt;BR /&gt;
Array Bal(36) balance1-balance36;&lt;BR /&gt;
&lt;BR /&gt;
if num &amp;gt; 18 then&lt;BR /&gt;
    maxbal = max(of Bal(num) - Bal(num-18), 0);&lt;BR /&gt;
else&lt;BR /&gt;
    maxbal = max(of Bal(num) - Bal(1) , 0 );</description>
    <pubDate>Thu, 12 Mar 2009 14:49:05 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-03-12T14:49:05Z</dc:date>
    <item>
      <title>Max function and array</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Max-function-and-array/m-p/76906#M7625</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
Is it possible to find the maximum entry in an array using max function?? The problem is that at each record, there is a different starting point in the array. e,g, &lt;BR /&gt;
&lt;BR /&gt;
Array Bal(36) balance1-balance36;&lt;BR /&gt;
&lt;BR /&gt;
if num &amp;gt; 18 then&lt;BR /&gt;
    maxbal = max(of Bal(num) - Bal(num-18), 0);&lt;BR /&gt;
else&lt;BR /&gt;
    maxbal = max(of Bal(num) - Bal(1) , 0 );</description>
      <pubDate>Thu, 12 Mar 2009 14:49:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Max-function-and-array/m-p/76906#M7625</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-03-12T14:49:05Z</dc:date>
    </item>
    <item>
      <title>Re: Max function and array</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Max-function-and-array/m-p/76907#M7626</link>
      <description>I'm sure there are multiple good solutions here. Since the MAX function isn't too fancy, I actually found it easier to write some code that avoids using the function.&lt;BR /&gt;
&lt;BR /&gt;
%let levels=18;&lt;BR /&gt;
  /* Setting this up as a macro variable&lt;BR /&gt;
  makes it easy to change */&lt;BR /&gt;
&lt;BR /&gt;
data test;&lt;BR /&gt;
  set whatever;&lt;BR /&gt;
  array Bal&lt;LI&gt; balance1-balance36;&lt;BR /&gt;
  MaxBal=0;&lt;BR /&gt;
  &lt;BR /&gt;
  /* Create lower limit for DO loop */&lt;BR /&gt;
  if num &amp;gt;= &amp;amp;levels then&lt;BR /&gt;
    bottom = num - &amp;amp;levels + 1;&lt;BR /&gt;
  else bottom = 1;&lt;BR /&gt;
&lt;BR /&gt;
  /* Cycle from bottom to the value of num */&lt;BR /&gt;
  do i = bottom to num;&lt;BR /&gt;
    if Bal{i} &amp;gt; MaxBal then&lt;BR /&gt;
      MaxBal = Bal{i};&lt;BR /&gt;
  end;&lt;BR /&gt;
&lt;BR /&gt;
drop i;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
In the future, you might have a little more luck posting to the DATA step board for responses on topics like this. No worries though!&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/forum.jspa?forumID=31" target="_blank"&gt;http://support.sas.com/forums/forum.jspa?forumID=31&lt;/A&gt;&lt;/LI&gt;</description>
      <pubDate>Mon, 16 Mar 2009 18:10:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Max-function-and-array/m-p/76907#M7626</guid>
      <dc:creator>RichardH_sas</dc:creator>
      <dc:date>2009-03-16T18:10:57Z</dc:date>
    </item>
  </channel>
</rss>

