<?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 how to conduct vectorized summation in SAS/IML in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-conduct-vectorized-summation-in-SAS-IML/m-p/663139#M5169</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I am building a formula which shows below by referring &lt;A href="https://blogs.sas.com/content/iml/2015/04/22/sum-a-series.html" target="_self"&gt;Sum a series in SAS &lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="截屏2020-06-19上午12.18.35.png" style="width: 122px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/46346i074195C789C20FFE/image-dimensions/122x61?v=v2" width="122" height="61" role="button" title="截屏2020-06-19上午12.18.35.png" alt="截屏2020-06-19上午12.18.35.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;When I run,&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;start Sumcon(n);
   i = 1:n;                    /* index of terms */
   return( sum((deltak/k[i]##2)#exp(r[i]#T[i])#Q[i]) );  /* sum of terms */
finish;
n = T(1:68);
sum = j(nrow(n),1);     /* allocate a vector for the results */
do k = 1 to nrow(n);
   sum[k] = Sumcon( n[k] );
end;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P class="p1"&gt;It returns ERROR: (execution) Matrix has not been set to a value.&lt;/P&gt;&lt;P class="p1"&gt;where the variables k, r, t, Q are all (68,1) vectors, the deltak is a fixed value 5.&lt;/P&gt;&lt;P class="p1"&gt;How can I achieve this formula?&lt;/P&gt;&lt;P class="p1"&gt;Thanks a lot.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 18 Jun 2020 12:31:19 GMT</pubDate>
    <dc:creator>Sasulee</dc:creator>
    <dc:date>2020-06-18T12:31:19Z</dc:date>
    <item>
      <title>how to conduct vectorized summation in SAS/IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-conduct-vectorized-summation-in-SAS-IML/m-p/663139#M5169</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I am building a formula which shows below by referring &lt;A href="https://blogs.sas.com/content/iml/2015/04/22/sum-a-series.html" target="_self"&gt;Sum a series in SAS &lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="截屏2020-06-19上午12.18.35.png" style="width: 122px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/46346i074195C789C20FFE/image-dimensions/122x61?v=v2" width="122" height="61" role="button" title="截屏2020-06-19上午12.18.35.png" alt="截屏2020-06-19上午12.18.35.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;When I run,&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;start Sumcon(n);
   i = 1:n;                    /* index of terms */
   return( sum((deltak/k[i]##2)#exp(r[i]#T[i])#Q[i]) );  /* sum of terms */
finish;
n = T(1:68);
sum = j(nrow(n),1);     /* allocate a vector for the results */
do k = 1 to nrow(n);
   sum[k] = Sumcon( n[k] );
end;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P class="p1"&gt;It returns ERROR: (execution) Matrix has not been set to a value.&lt;/P&gt;&lt;P class="p1"&gt;where the variables k, r, t, Q are all (68,1) vectors, the deltak is a fixed value 5.&lt;/P&gt;&lt;P class="p1"&gt;How can I achieve this formula?&lt;/P&gt;&lt;P class="p1"&gt;Thanks a lot.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 12:31:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-conduct-vectorized-summation-in-SAS-IML/m-p/663139#M5169</guid>
      <dc:creator>Sasulee</dc:creator>
      <dc:date>2020-06-18T12:31:19Z</dc:date>
    </item>
    <item>
      <title>Re: how to conduct vectorized summation in SAS/IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-conduct-vectorized-summation-in-SAS-IML/m-p/663143#M5170</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;ERROR: (execution) Matrix has not been set to a value.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Print out each of the matrices involved and see which one(s) do not have values.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 12:39:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-conduct-vectorized-summation-in-SAS-IML/m-p/663143#M5170</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-06-18T12:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: how to conduct vectorized summation in SAS/IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-conduct-vectorized-summation-in-SAS-IML/m-p/663147#M5171</link>
      <description>Thanks for replying. However, every column is valued. Is it caused by incorrect use of the sum function?</description>
      <pubDate>Thu, 18 Jun 2020 12:52:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-conduct-vectorized-summation-in-SAS-IML/m-p/663147#M5171</guid>
      <dc:creator>Sasulee</dc:creator>
      <dc:date>2020-06-18T12:52:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to conduct vectorized summation in SAS/IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-conduct-vectorized-summation-in-SAS-IML/m-p/663149#M5172</link>
      <description>&lt;P&gt;The vectors are not in scope inside the function. You either need to pass them in or use a GLOBAL statement. See &lt;A href="https://blogs.sas.com/content/iml/2013/04/29/understanding-local-and-global-variables-in-the-sasiml-language.html" target="_self"&gt;"Understanding local and global variables in the SAS/IML language."&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 12:57:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-conduct-vectorized-summation-in-SAS-IML/m-p/663149#M5172</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-06-18T12:57:29Z</dc:date>
    </item>
    <item>
      <title>Re: how to conduct vectorized summation in SAS/IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-conduct-vectorized-summation-in-SAS-IML/m-p/663152#M5173</link>
      <description>&lt;P&gt;Here is how I would compute the sum. I am using 5-dimensional vectors instead of 68 elements:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
/* Use n = 5 instead of 68.
   Make up some fake values for the column vectors k, r, t, Q */
k = {1,2,3,4,5};
r = {1,2,3,4,5} / 5;
T = {1,2,3,4,5} / 10;
Q = {1,2,3,4,5} / 15;
deltak = 2;

v = deltak/k##2 # exp(r#T)#Q;
sum = sum(v);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Jun 2020 13:05:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-conduct-vectorized-summation-in-SAS-IML/m-p/663152#M5173</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-06-18T13:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: how to conduct vectorized summation in SAS/IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-conduct-vectorized-summation-in-SAS-IML/m-p/663341#M5174</link>
      <description>Why r, t, Q should divide by 5, 10, 15 respectively? how can I express this when read all var?</description>
      <pubDate>Thu, 18 Jun 2020 22:54:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-conduct-vectorized-summation-in-SAS-IML/m-p/663341#M5174</guid>
      <dc:creator>Sasulee</dc:creator>
      <dc:date>2020-06-18T22:54:13Z</dc:date>
    </item>
    <item>
      <title>Re: how to conduct vectorized summation in SAS/IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-conduct-vectorized-summation-in-SAS-IML/m-p/663400#M5175</link>
      <description>&lt;P&gt;Please take another look at Rick's post above, as I think it is the solution that you want. Ignore everything up to deltak=2, as this is artificial data to show that the solution works. Try to include the last 2 lines in your own code, and tell us what happens.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jun 2020 07:12:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-conduct-vectorized-summation-in-SAS-IML/m-p/663400#M5175</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2020-06-19T07:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: how to conduct vectorized summation in SAS/IML</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-conduct-vectorized-summation-in-SAS-IML/m-p/663411#M5176</link>
      <description>&lt;P&gt;The comment in my program says "&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #708090; font-family: Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-shadow: 0px 1px white; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;Make up some fake values for the column vectors k, r, t, Q&lt;/SPAN&gt;"&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #333333; cursor: text; font-family: Arial,Helvetica,sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 27.42px; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;Thus, these are fake values. Not real. Made up. Use your values instead.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jun 2020 09:33:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/how-to-conduct-vectorized-summation-in-SAS-IML/m-p/663411#M5176</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-06-19T09:33:00Z</dc:date>
    </item>
  </channel>
</rss>

