<?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 Sigma Summation in sas in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Sigma-Summation-in-sas/m-p/197181#M36974</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: Arial, sans-serif; font-size: 13px; background-color: #f6f7f7;"&gt; How do we go about inserting mathematical functions like this into sas? Sum(i in 1 to n-2) (&lt;I&gt;* Floor (n/&lt;I&gt;) where n is just the natural numbers.&lt;/I&gt;&lt;/I&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: Arial, sans-serif; font-size: 13px; background-color: #f6f7f7;"&gt;I just want to output two columns, one for the natural numbers and one for out come of the summation above.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: Arial, sans-serif; font-size: 13px; background-color: #f6f7f7;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Apr 2015 09:08:03 GMT</pubDate>
    <dc:creator>Tim123</dc:creator>
    <dc:date>2015-04-16T09:08:03Z</dc:date>
    <item>
      <title>Sigma Summation in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sigma-Summation-in-sas/m-p/197181#M36974</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: Arial, sans-serif; font-size: 13px; background-color: #f6f7f7;"&gt; How do we go about inserting mathematical functions like this into sas? Sum(i in 1 to n-2) (&lt;I&gt;* Floor (n/&lt;I&gt;) where n is just the natural numbers.&lt;/I&gt;&lt;/I&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: Arial, sans-serif; font-size: 13px; background-color: #f6f7f7;"&gt;I just want to output two columns, one for the natural numbers and one for out come of the summation above.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: Arial, sans-serif; font-size: 13px; background-color: #f6f7f7;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2015 09:08:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sigma-Summation-in-sas/m-p/197181#M36974</guid>
      <dc:creator>Tim123</dc:creator>
      <dc:date>2015-04-16T09:08:03Z</dc:date>
    </item>
    <item>
      <title>Re: Sigma Summation in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sigma-Summation-in-sas/m-p/197182#M36975</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This formula could be part of a DO loop in a data step. You could also program this in loop in PROC IML.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2015 12:11:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sigma-Summation-in-sas/m-p/197182#M36975</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2015-04-16T12:11:10Z</dc:date>
    </item>
    <item>
      <title>Re: Sigma Summation in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sigma-Summation-in-sas/m-p/197183#M36976</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV style="color: #000000; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;"&gt;data some_numbers;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #000000; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;"&gt;n=0;&lt;/P&gt;&lt;P style="color: #000000; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;"&gt;a=0;&lt;/P&gt;&lt;P style="color: #000000; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;"&gt;b=0;&lt;/P&gt;&lt;P style="color: #000000; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;"&gt;do while(n&amp;lt;1000);&lt;/P&gt;&lt;P style="color: #000000; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;"&gt;&amp;nbsp;&amp;nbsp; a= (&lt;SPAN style="color: #006fc9;"&gt;here is my problem, I want a to be &lt;SPAN style="color: #333333; font-family: Arial, sans-serif; font-size: 13px; background-color: #f6f7f7;"&gt; Sum(i in 1 to n-2) (&lt;I&gt;* Floor (n/&lt;I&gt;)&lt;/I&gt;&lt;/I&gt;&lt;/SPAN&gt;) &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #000000; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;"&gt;output;&lt;/P&gt;&lt;P style="color: #000000; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;"&gt;n=n+1;&lt;/P&gt;&lt;P style="color: #000000; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;"&gt;end;&lt;/P&gt;&lt;P style="color: #000000; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;"&gt;run;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;my over all aim is just to have two columns, one with just n=0 to 1000 or so, and the second column is (a) as above. however my above code wouldn't accept this difficult&amp;nbsp; for (a).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2015 13:11:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sigma-Summation-in-sas/m-p/197183#M36976</guid>
      <dc:creator>Tim123</dc:creator>
      <dc:date>2015-04-16T13:11:47Z</dc:date>
    </item>
    <item>
      <title>Re: Sigma Summation in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sigma-Summation-in-sas/m-p/197184#M36977</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Provide what you are expecting for the first 3 or 4 outputs (at least). I suspect you may not be expressing your problem quite concisely.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can factor out the &lt;I&gt;* bit as a constant times each member of series: &lt;I&gt; * (first term) + &lt;I&gt;*(second term + ... +&lt;I&gt;*(nth term) = &lt;I&gt;* sum of terms. So &lt;I&gt; * sum of Floor(n/&lt;I&gt;).&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;HOWEVER: You have issues with&amp;nbsp; the value of &lt;I&gt; is going to hit 0 in three iterations as n-2 will be -2 , -1 and 0 and hence undefined.&lt;/I&gt;&lt;/P&gt;&lt;P&gt;Maybe you want to start with n=3?&lt;/P&gt;&lt;P&gt;I think you are looking, in a more general sense for :&lt;/P&gt;&lt;P style="color: #000000; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;"&gt;do while(n&amp;lt;1000);&lt;/P&gt;&lt;P style="color: #000000; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a=0;&lt;/P&gt;&lt;P style="color: #000000; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i =1 to (n-2);&lt;/P&gt;&lt;P style="color: #000000; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a= a+ &lt;SPAN style="color: #006fc9;"&gt;&lt;SPAN style="color: #333333; font-family: Arial, sans-serif; font-size: 13px; background-color: #f6f7f7;"&gt;(i* Floor (n/i)&lt;/SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #000000; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;"&gt;&lt;SPAN style="color: #006fc9;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #000000; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;"&gt;output;&lt;/P&gt;&lt;P style="color: #000000; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;"&gt;n=n+1;&lt;/P&gt;&lt;P style="color: #000000; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;"&gt;end;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2015 14:32:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sigma-Summation-in-sas/m-p/197184#M36977</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-04-16T14:32:54Z</dc:date>
    </item>
    <item>
      <title>Re: Sigma Summation in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sigma-Summation-in-sas/m-p/197185#M36978</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It sounds like you're treating your data like a matrix and may want to look at SAS/IML.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BASE/SAS programming doesn't quite work the same way, so you need to change the way you think a bit.&amp;nbsp; It process each line and then moves onto the next, with exceptions that can be programmed in. This method means it doesn't need to read all of the data into memory which is why it handles big data with the same code as small data in a straightforward manner. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At any rate, you need to go back to basic looping structures then when you want to do summations.&amp;nbsp; Post an example of the data you have and the output you expect. If you're looking to use SAS/IML which is closer to R then mention that as well. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2015 14:40:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sigma-Summation-in-sas/m-p/197185#M36978</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-04-16T14:40:47Z</dc:date>
    </item>
    <item>
      <title>Re: Sigma Summation in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sigma-Summation-in-sas/m-p/197186#M36979</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The data step is easy:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data series;&lt;BR /&gt;do n = 3 to 10;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; sum = 0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; do i = 1 to n-2;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum = sum + i/ floor(n/i);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; output;&lt;BR /&gt;end;&lt;BR /&gt;keep n sum;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In IML, you can loop over the values of n:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc iml;&lt;/P&gt;&lt;P&gt;n = T(3:10);&lt;/P&gt;&lt;P&gt;sum = j(nrow(n),1);&lt;/P&gt;&lt;P&gt;do k = 1 to nrow(n);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; i = 1:(n&lt;K&gt;-2);&lt;/K&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; sum&lt;K&gt; = sum( i / floor( n&lt;K&gt; / i ) );&lt;/K&gt;&lt;/K&gt;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;print n sum;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to get fancy, you can also do compute the summations for all values of n without any loops by using matrices.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2015 18:25:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sigma-Summation-in-sas/m-p/197186#M36979</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-04-16T18:25:28Z</dc:date>
    </item>
    <item>
      <title>Re: Sigma Summation in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sigma-Summation-in-sas/m-p/197187#M36980</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;See &lt;A href="http://blogs.sas.com/content/iml/2015/04/22/sum-a-series.html"&gt;"How to sum a series in SAS"&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Apr 2015 13:41:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sigma-Summation-in-sas/m-p/197187#M36980</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-04-23T13:41:58Z</dc:date>
    </item>
  </channel>
</rss>

