<?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: Select maximum variable in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-maximum-variable/m-p/178885#M13680</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I ended up doing it like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if var1 ne 1 then val1 = '';&lt;/P&gt;&lt;P&gt;if var6 ne 1 then val2 = '';&lt;/P&gt;&lt;P&gt;if var6 ne 1 then val3 = '';&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;if var6 ne 1 then val6 = '';&lt;/P&gt;&lt;P&gt;balance = max(of val1-val6);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks everyone for your help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marco&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 14 Apr 2014 13:44:44 GMT</pubDate>
    <dc:creator>Lupacante</dc:creator>
    <dc:date>2014-04-14T13:44:44Z</dc:date>
    <item>
      <title>Select maximum variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-maximum-variable/m-p/178878#M13673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a dataset with column headings as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;account number | var1 | val1 | var2 | val2 | var3 | val3 | var4 | val4 | var5 | val5 | var6 | val6 |&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this is what I would like to do:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if var1 = 1 then balance = val1;&lt;/P&gt;&lt;P&gt;if var2 = 1 then balance = val2;&lt;/P&gt;&lt;P&gt;if var3 = 1 then balance = val3;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;if var6 = 1 then balance = val6;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, for some account numbers, multiple vars are equal to one. I might have this situation:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;account number | var1 | val1 | var2 | val2 | var3 | val3 | var4 | val4 | var5 | val5 | var6 | val6 |&lt;/P&gt;&lt;P&gt;123456&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | 512 | 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | 625 |&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this case, I would like to take make 'balance' equal to the highest 'val' there is. So as var1 and var2 are both equal to 1, I would like balance to equal the highest value of the relative vals. In this case, 625.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks in advance,&lt;/P&gt;&lt;P&gt;Marco&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Apr 2014 11:27:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-maximum-variable/m-p/178878#M13673</guid>
      <dc:creator>Lupacante</dc:creator>
      <dc:date>2014-04-14T11:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: Select maximum variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-maximum-variable/m-p/178879#M13674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use your original code :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;if var1 = 1 then balance = val1;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;if var2 = 1 then balance = val2;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;if var3 = 1 then balance = val3;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;...&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;if var6 = 1 then balance = val6;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Apr 2014 12:02:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-maximum-variable/m-p/178879#M13674</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-04-14T12:02:52Z</dc:date>
    </item>
    <item>
      <title>Re: Select maximum variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-maximum-variable/m-p/178880#M13675</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Assuming that 1 only appears if a value is present, try max function:&lt;/P&gt;&lt;P&gt;max(val1-val6).&lt;/P&gt;&lt;P&gt;In case you do not know how many variables then query the sashelp tables.&lt;/P&gt;&lt;P&gt;This will return the largest number from val1-6.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Apr 2014 12:12:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-maximum-variable/m-p/178880#M13675</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-04-14T12:12:19Z</dc:date>
    </item>
    <item>
      <title>Re: Select maximum variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-maximum-variable/m-p/178881#M13676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since I hate to write the same code repeatedly, I've put in a macro.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro work;&lt;/P&gt;&lt;P&gt;%do i = 1 %to 6;&lt;/P&gt;&lt;P&gt;if var&amp;amp;i = 1&lt;/P&gt;&lt;P&gt;then balance = max(balance, val&amp;amp;i);&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;balance = 0;&lt;/P&gt;&lt;P&gt;%work;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Apr 2014 12:13:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-maximum-variable/m-p/178881#M13676</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2014-04-14T12:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: Select maximum variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-maximum-variable/m-p/178882#M13677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think that wouldn't work with those if statements as you would set balance to the last non-missing value.&amp;nbsp; What you want is:&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;if var1 = 1 and val1 &amp;gt; balance then balance = val1;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;...&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;if var6 = 1 and val6 &amp;gt; balance then balance = val6;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Apr 2014 12:13:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-maximum-variable/m-p/178882#M13677</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-04-14T12:13:48Z</dc:date>
    </item>
    <item>
      <title>Re: Select maximum variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-maximum-variable/m-p/178883#M13678</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or, without macro:&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('data want; set have;');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do I=1 to 6;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('if var'||put(i,1.)||'=1 and val'||put(I,1.)||' &amp;gt; balance then balance=val'||put(I,1.)||';');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('run;');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Apr 2014 12:16:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-maximum-variable/m-p/178883#M13678</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-04-14T12:16:01Z</dc:date>
    </item>
    <item>
      <title>Re: Select maximum variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-maximum-variable/m-p/178884#M13679</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;
&lt;P&gt;RW9 wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Assuming that 1 only appears if a value is present, try max function:&lt;/P&gt;
&lt;P&gt;max(val1-val6).&lt;/P&gt;
&lt;P&gt;In case you do not know how many variables then query the sashelp tables.&lt;/P&gt;
&lt;P&gt;This will return the largest number from val1-6.&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;You may want to test this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your usage of (VAL1 - VAL6) is an expression not a "SAS Variable List".&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Apr 2014 13:35:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-maximum-variable/m-p/178884#M13679</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-04-14T13:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: Select maximum variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-maximum-variable/m-p/178885#M13680</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I ended up doing it like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if var1 ne 1 then val1 = '';&lt;/P&gt;&lt;P&gt;if var6 ne 1 then val2 = '';&lt;/P&gt;&lt;P&gt;if var6 ne 1 then val3 = '';&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;if var6 ne 1 then val6 = '';&lt;/P&gt;&lt;P&gt;balance = max(of val1-val6);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks everyone for your help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marco&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Apr 2014 13:44:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-maximum-variable/m-p/178885#M13680</guid>
      <dc:creator>Lupacante</dc:creator>
      <dc:date>2014-04-14T13:44:44Z</dc:date>
    </item>
    <item>
      <title>Re: Select maximum variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-maximum-variable/m-p/178886#M13681</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, you are totally correct data _null_;.&amp;nbsp; The syntax is:&lt;/P&gt;&lt;P&gt;max(of val1-val6);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Apr 2014 13:45:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-maximum-variable/m-p/178886#M13681</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-04-14T13:45:37Z</dc:date>
    </item>
    <item>
      <title>Re: Select maximum variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-maximum-variable/m-p/178887#M13682</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;But keep in mind that now you modify the values of var1 ... var6 before writing.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Apr 2014 13:50:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-maximum-variable/m-p/178887#M13682</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2014-04-14T13:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: Select maximum variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-maximum-variable/m-p/178888#M13683</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;True, I do modify val1-val6, but I only need them in this step.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Apr 2014 13:53:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Select-maximum-variable/m-p/178888#M13683</guid>
      <dc:creator>Lupacante</dc:creator>
      <dc:date>2014-04-14T13:53:11Z</dc:date>
    </item>
  </channel>
</rss>

