<?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: Find two best rates from list of 6 variables and corresponding amounts to match in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-two-best-rates-from-list-of-6-variables-and-corresponding/m-p/749018#M235318</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/149821"&gt;@bibbnd&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;i figured it out&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Good job.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now post your solution so if someone finds this thread in a search for similar problems they can find your solution.&lt;/P&gt;
&lt;P&gt;After posting your solution mark it as the accepted solution so people will know there was a solution.&lt;/P&gt;</description>
    <pubDate>Sat, 19 Jun 2021 07:55:03 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-06-19T07:55:03Z</dc:date>
    <item>
      <title>Find two best rates from list of 6 variables and corresponding amounts to match</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-two-best-rates-from-list-of-6-variables-and-corresponding/m-p/748593#M235095</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need two search a series of 7 variables for the best rate based on the character string of a 4D or 5D. If the best rate has these values then i need to capture their corresponding rate values also. So eventually i want to keep the rates with 4D or 5D and their rate_amts in new fields such as rateA, rateA_amt and rateB, rateB_amt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i started the code like this but not sure how to proceed&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;set vgrid;&lt;/P&gt;&lt;P&gt;ARRAY RATE[*] $18 RCOMPARED1-RCOMPARED7;&lt;/P&gt;&lt;P&gt;array rateA[*]&amp;nbsp; $18;&lt;/P&gt;&lt;P&gt;array rateB[*] $18;&lt;/P&gt;&lt;P&gt;array rateA_amt[*] 10.2;&lt;/P&gt;&lt;P&gt;array rateB_amt[*] 10.2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DO i to dim;&lt;/P&gt;&lt;P&gt;if index(rate(i), '4D') &amp;gt; 0 OR index(rate(i), '5D') &amp;gt; 0 THEN DO;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*this is where i am not sure what to do next to capture only those rates and their corresponding amts to output&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jun 2021 01:41:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-two-best-rates-from-list-of-6-variables-and-corresponding/m-p/748593#M235095</guid>
      <dc:creator>bibbnd</dc:creator>
      <dc:date>2021-06-17T01:41:14Z</dc:date>
    </item>
    <item>
      <title>Re: Find two best rates from list of 6 variables and corresponding amounts to match</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-two-best-rates-from-list-of-6-variables-and-corresponding/m-p/748598#M235099</link>
      <description>&lt;P&gt;Some sort of complete data might help. And then what the result would be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your intent with the Rate arrays was to create multiple variables then your syntax is incorrect. If you intend to reference existing variables you need to name them. If you are creating an array of new variables you have to specify how many variables.&lt;/P&gt;
&lt;P&gt;Array RateA (7) ;&lt;/P&gt;
&lt;P&gt;would create 7 variables named RateA1, RateA2, ....,RateA7.&lt;/P&gt;
&lt;P&gt;If you want to know which element of an array holds a specific value then you use the WHICHC, for character variables, or WHICHN for numeric:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Vnum = whichc('4D', of rate(*));&lt;/P&gt;
&lt;P&gt;If Vnum &amp;gt; 0 then somevalue = nameofarray[Vnum];&lt;/P&gt;
&lt;P&gt;would return the first position that '4D' is found in the Rate array and then use that value to find the corresponding value in another array.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Details come in with what to do when '4D' or '5D' repeat or are both found in a single observation.&lt;/P&gt;
&lt;P&gt;Which is why a more complete example of data with ALL the variables and what you expect the result to be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jun 2021 03:57:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-two-best-rates-from-list-of-6-variables-and-corresponding/m-p/748598#M235099</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-06-17T03:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: Find two best rates from list of 6 variables and corresponding amounts to match</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-two-best-rates-from-list-of-6-variables-and-corresponding/m-p/748602#M235103</link>
      <description>&lt;P&gt;Post representative sample data provided via a SAS data step creating the data and show us the expected result using this data.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jun 2021 04:36:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-two-best-rates-from-list-of-6-variables-and-corresponding/m-p/748602#M235103</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-06-17T04:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: Find two best rates from list of 6 variables and corresponding amounts to match</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-two-best-rates-from-list-of-6-variables-and-corresponding/m-p/748771#M235185</link>
      <description>&lt;P&gt;i figured it out&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jun 2021 20:30:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-two-best-rates-from-list-of-6-variables-and-corresponding/m-p/748771#M235185</guid>
      <dc:creator>bibbnd</dc:creator>
      <dc:date>2021-06-17T20:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: Find two best rates from list of 6 variables and corresponding amounts to match</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-two-best-rates-from-list-of-6-variables-and-corresponding/m-p/749018#M235318</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/149821"&gt;@bibbnd&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;i figured it out&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Good job.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now post your solution so if someone finds this thread in a search for similar problems they can find your solution.&lt;/P&gt;
&lt;P&gt;After posting your solution mark it as the accepted solution so people will know there was a solution.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Jun 2021 07:55:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-two-best-rates-from-list-of-6-variables-and-corresponding/m-p/749018#M235318</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-06-19T07:55:03Z</dc:date>
    </item>
    <item>
      <title>Re: Find two best rates from list of 6 variables and corresponding amounts to match</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-two-best-rates-from-list-of-6-variables-and-corresponding/m-p/749400#M235484</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;data test;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;&amp;nbsp;set rates_all;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;Format&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; new_best_rate other_rate &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#08726d"&gt;$18.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;array&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; rate[*] $&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#08726d"&gt;18&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; current_rate best_rate ratecompared1 - ratecompared5;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;array&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ramt[*] current_amt bestrate_amt ratecompared_amt1 -&amp;nbsp;ratecompared_amt5;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*intializing new variables;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;new_best_rate=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;' '&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;new_bestrate_amt=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#08726d"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;new_savings=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#08726d"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;other_rate=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;' '&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;other_amt=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#08726d"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; i= &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#08726d"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;to&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; dim(rate);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; indexc(rate{i},&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'4'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#08726d"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;OR&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; indexc(rate{i},&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'5'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#08726d"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;then&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; new_bestrate_amt ne &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#08726d"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;then&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;other_rate=rate{i};&lt;/P&gt;&lt;P&gt;other_amt=ramt{i};&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;else&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;new_best_rate = rate{i};&lt;/P&gt;&lt;P&gt;new_bestrate_amt = ramt{i};&lt;/P&gt;&lt;P&gt;new_savings=(current_amt-ramt{i});&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;END&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;END&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 23:55:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-two-best-rates-from-list-of-6-variables-and-corresponding/m-p/749400#M235484</guid>
      <dc:creator>bibbnd</dc:creator>
      <dc:date>2021-06-21T23:55:53Z</dc:date>
    </item>
  </channel>
</rss>

