<?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: using the array to find averages of any two numbers from a set of numbers in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/using-the-array-to-find-averages-of-any-two-numbers-from-a-set/m-p/609442#M177436</link>
    <description>Wonderful! This is exactly what I've been looking for. Thank you so much for helping me!! I greatly appreciate your help!</description>
    <pubDate>Wed, 04 Dec 2019 16:53:31 GMT</pubDate>
    <dc:creator>Amy0223</dc:creator>
    <dc:date>2019-12-04T16:53:31Z</dc:date>
    <item>
      <title>using the array to find averages of any two numbers from a set of numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-the-array-to-find-averages-of-any-two-numbers-from-a-set/m-p/609270#M177384</link>
      <description>&lt;P&gt;Hi, I'm not sure how to code the problem below. Your kind help is greatly appreciated!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Given the set of numbers: 11, 23, 17, 39, 50, using the array to find averages of any two numbers from a set of numbers. The two numbers can be the same. &lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 06:21:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-the-array-to-find-averages-of-any-two-numbers-from-a-set/m-p/609270#M177384</guid>
      <dc:creator>Amy0223</dc:creator>
      <dc:date>2019-12-04T06:21:26Z</dc:date>
    </item>
    <item>
      <title>Re: using the array to find averages of any two numbers from a set of numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-the-array-to-find-averages-of-any-two-numbers-from-a-set/m-p/609279#M177389</link>
      <description>&lt;P&gt;Use two nested do loops (assuming n to be the number of elements): one counts index1 from 1 to n-1, and the inner loop from index1+1 to n. Build the average of array{index1} and array{index2}.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 06:42:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-the-array-to-find-averages-of-any-two-numbers-from-a-set/m-p/609279#M177389</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-12-04T06:42:58Z</dc:date>
    </item>
    <item>
      <title>Re: using the array to find averages of any two numbers from a set of numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-the-array-to-find-averages-of-any-two-numbers-from-a-set/m-p/609346#M177406</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265801"&gt;@Amy0223&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does the following code answer your question?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	array number(5) (11 23 17 39 50);
	do i=1 to dim(number);
		do j=i to dim(number);
			couple_1 = number(i);
			couple_2 = number(j);
			average = mean(number(i),number(j));
			output;
		end;
	end;
	keep couple_1 couple_2 average;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Capture d’écran 2019-12-04 à 07.26.29.png" style="width: 177px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34443i3DDF18AB186C2B72/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture d’écran 2019-12-04 à 07.26.29.png" alt="Capture d’écran 2019-12-04 à 07.26.29.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 12:38:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-the-array-to-find-averages-of-any-two-numbers-from-a-set/m-p/609346#M177406</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2019-12-04T12:38:46Z</dc:date>
    </item>
    <item>
      <title>Re: using the array to find averages of any two numbers from a set of numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-the-array-to-find-averages-of-any-two-numbers-from-a-set/m-p/609349#M177407</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265801"&gt;@Amy0223&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;wrote do it with double loop.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure what do you mean by "&lt;STRONG&gt;The two numbers can be the same.&lt;/STRONG&gt;", is it that you want also pair of (first,first), (second,second), (third, third) etc. or that just values can repeat? If you mean first option then change `next` macrovariable to 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let next = 1;

data want;
  array A[5] _temporary_ (11, 23, 17, 39, 50);

  do i = 1 to dim(a);
    do j = i + &amp;amp;next. to dim(a);
      first  = a[i];
      second = a[j];
      avg = mean(first, second);
      output;
    end;
  end;
  drop i j;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;All the bets&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 12:33:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-the-array-to-find-averages-of-any-two-numbers-from-a-set/m-p/609349#M177407</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2019-12-04T12:33:48Z</dc:date>
    </item>
    <item>
      <title>Re: using the array to find averages of any two numbers from a set of numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-the-array-to-find-averages-of-any-two-numbers-from-a-set/m-p/609442#M177436</link>
      <description>Wonderful! This is exactly what I've been looking for. Thank you so much for helping me!! I greatly appreciate your help!</description>
      <pubDate>Wed, 04 Dec 2019 16:53:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-the-array-to-find-averages-of-any-two-numbers-from-a-set/m-p/609442#M177436</guid>
      <dc:creator>Amy0223</dc:creator>
      <dc:date>2019-12-04T16:53:31Z</dc:date>
    </item>
    <item>
      <title>Re: using the array to find averages of any two numbers from a set of numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-the-array-to-find-averages-of-any-two-numbers-from-a-set/m-p/609443#M177437</link>
      <description>Thank you so much!! I greatly appreciate your help!</description>
      <pubDate>Wed, 04 Dec 2019 16:54:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-the-array-to-find-averages-of-any-two-numbers-from-a-set/m-p/609443#M177437</guid>
      <dc:creator>Amy0223</dc:creator>
      <dc:date>2019-12-04T16:54:16Z</dc:date>
    </item>
    <item>
      <title>Re: using the array to find averages of any two numbers from a set of numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-the-array-to-find-averages-of-any-two-numbers-from-a-set/m-p/609461#M177445</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265801"&gt;@Amy0223&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 17:37:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-the-array-to-find-averages-of-any-two-numbers-from-a-set/m-p/609461#M177445</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2019-12-04T17:37:37Z</dc:date>
    </item>
  </channel>
</rss>

