<?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: array for sumproduct across variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/array-for-sumproduct-across-variables/m-p/174046#M33436</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Reeza. I tried that but still end result of sumproduct didn't give the expected result. started with 3 values, instead of 1000 and expected result for sumproduct is 14 =&amp;nbsp; (1*1) + (2*2) + (3*3 )&amp;nbsp; which isn't coming with this code&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;data test;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array xvals{1:3} _TEMPORARY_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array yvals{1:3} _TEMPORARY_;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;sumproduct=0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;&amp;nbsp; do i=1 to 3;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sumproduct=sumproduct+xvals(i)*yvals(i); &lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 13 Feb 2014 21:59:25 GMT</pubDate>
    <dc:creator>nash_sas</dc:creator>
    <dc:date>2014-02-13T21:59:25Z</dc:date>
    <item>
      <title>array for sumproduct across variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array-for-sumproduct-across-variables/m-p/174044#M33434</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Need help to finish the below code to get sumproduct with arrays. Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp; array xvals{1:1000} _TEMPORARY_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array yvals{1:1000} _TEMPORARY_;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp; do i=1 to 1000;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sumproduct=sum(of xvals(i)*yvals(i)); /* I am stuck here ???*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Feb 2014 21:26:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array-for-sumproduct-across-variables/m-p/174044#M33434</guid>
      <dc:creator>nash_sas</dc:creator>
      <dc:date>2014-02-13T21:26:41Z</dc:date>
    </item>
    <item>
      <title>Re: array for sumproduct across variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array-for-sumproduct-across-variables/m-p/174045#M33435</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You're not retaining anything between loop iterations, so the value you're getting, summing it doesn't error out, is the last summation. &lt;/P&gt;&lt;P&gt;This assumes that you want the sum of xvals(i)*yvals(i) and not something else. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array xvals{1:1000} _TEMPORARY_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array yvals{1:1000} _TEMPORARY_;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;sumproduct=0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; do i=1 to 1000;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sumproduct=sumproduct+xvals(i)*yvals(i); /* I am stuck here ???*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Feb 2014 21:48:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array-for-sumproduct-across-variables/m-p/174045#M33435</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-02-13T21:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: array for sumproduct across variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array-for-sumproduct-across-variables/m-p/174046#M33436</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Reeza. I tried that but still end result of sumproduct didn't give the expected result. started with 3 values, instead of 1000 and expected result for sumproduct is 14 =&amp;nbsp; (1*1) + (2*2) + (3*3 )&amp;nbsp; which isn't coming with this code&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;data test;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array xvals{1:3} _TEMPORARY_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array yvals{1:3} _TEMPORARY_;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;sumproduct=0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;&amp;nbsp; do i=1 to 3;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sumproduct=sumproduct+xvals(i)*yvals(i); &lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Feb 2014 21:59:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array-for-sumproduct-across-variables/m-p/174046#M33436</guid>
      <dc:creator>nash_sas</dc:creator>
      <dc:date>2014-02-13T21:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: array for sumproduct across variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array-for-sumproduct-across-variables/m-p/174047#M33437</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Where do you put the values in the array?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Feb 2014 22:01:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array-for-sumproduct-across-variables/m-p/174047#M33437</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-02-13T22:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: array for sumproduct across variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array-for-sumproduct-across-variables/m-p/174048#M33438</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to give XVALS and YVALS some values.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Feb 2014 22:02:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array-for-sumproduct-across-variables/m-p/174048#M33438</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-02-13T22:02:13Z</dc:date>
    </item>
    <item>
      <title>Re: array for sumproduct across variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array-for-sumproduct-across-variables/m-p/174049#M33439</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array xvals{1:3} _TEMPORARY_ (1:3);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array yvals{1:3} _TEMPORARY_ (1:3);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sumproduct=0;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i=1 to dim(xvals);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sumproduct=sumproduct+xvals(i)*yvals(i);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Feb 2014 22:53:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array-for-sumproduct-across-variables/m-p/174049#M33439</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-02-13T22:53:38Z</dc:date>
    </item>
    <item>
      <title>Re: array for sumproduct across variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array-for-sumproduct-across-variables/m-p/174050#M33440</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Reeza. Finally I came up with the below solution to have sum product for all 1000 values (variables in case of my dataset). This is same as excel sumproduct with few lines of SAS code. Kudos !!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro vals;&lt;/P&gt;&lt;P&gt; %do i = 1 %to 1000;&lt;/P&gt;&lt;P&gt;&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 test;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp; array xvals{1000} _TEMPORARY_ (%vals); &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;array yvals{1000} _TEMPORARY_ (%vals);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;sumproduct = 0;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp; do i=1 to 1000;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp; sumproduct= sum(sumproduct, (xvals(i)*yvals(i)));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Feb 2014 23:47:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array-for-sumproduct-across-variables/m-p/174050#M33440</guid>
      <dc:creator>nash_sas</dc:creator>
      <dc:date>2014-02-13T23:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: array for sumproduct across variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array-for-sumproduct-across-variables/m-p/174051#M33441</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is the purpose of the ARRAYS?&amp;nbsp; You are summing i*i.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Feb 2014 23:52:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array-for-sumproduct-across-variables/m-p/174051#M33441</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-02-13T23:52:36Z</dc:date>
    </item>
  </channel>
</rss>

