<?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 Formula calculation in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Formula-calculation/m-p/448457#M69598</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone help the calculation of Y below using&amp;nbsp;SAS code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in 0in 10pt;"&gt;&lt;SPAN style="line-height: 115%; font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;"&gt;&lt;FONT color="#000000"&gt;Y=A*(B)&lt;SUP&gt;-1&lt;/SUP&gt;&lt;/FONT&gt;&lt;FONT color="#000000"&gt;+ A*(B)&lt;/FONT&gt;&lt;SUP&gt;&lt;FONT color="#000000"&gt;-2&lt;/FONT&gt;&lt;/SUP&gt;&lt;FONT color="#000000"&gt; + A*(B)&lt;/FONT&gt;&lt;SUP&gt;&lt;FONT color="#000000"&gt;-3&lt;/FONT&gt;&lt;/SUP&gt;&lt;FONT color="#000000"&gt; + A*(B)&lt;/FONT&gt;&lt;SUP&gt;&lt;FONT color="#000000"&gt;-4&lt;/FONT&gt;&lt;/SUP&gt;&lt;FONT color="#000000"&gt; +……+ A*(B)&lt;/FONT&gt;&lt;SUP&gt;&lt;FONT color="#000000"&gt;-N&lt;/FONT&gt;&lt;/SUP&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks a lot!&lt;/P&gt;</description>
    <pubDate>Sat, 24 Mar 2018 22:08:27 GMT</pubDate>
    <dc:creator>user1</dc:creator>
    <dc:date>2018-03-24T22:08:27Z</dc:date>
    <item>
      <title>Formula calculation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Formula-calculation/m-p/448457#M69598</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone help the calculation of Y below using&amp;nbsp;SAS code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in 0in 10pt;"&gt;&lt;SPAN style="line-height: 115%; font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;"&gt;&lt;FONT color="#000000"&gt;Y=A*(B)&lt;SUP&gt;-1&lt;/SUP&gt;&lt;/FONT&gt;&lt;FONT color="#000000"&gt;+ A*(B)&lt;/FONT&gt;&lt;SUP&gt;&lt;FONT color="#000000"&gt;-2&lt;/FONT&gt;&lt;/SUP&gt;&lt;FONT color="#000000"&gt; + A*(B)&lt;/FONT&gt;&lt;SUP&gt;&lt;FONT color="#000000"&gt;-3&lt;/FONT&gt;&lt;/SUP&gt;&lt;FONT color="#000000"&gt; + A*(B)&lt;/FONT&gt;&lt;SUP&gt;&lt;FONT color="#000000"&gt;-4&lt;/FONT&gt;&lt;/SUP&gt;&lt;FONT color="#000000"&gt; +……+ A*(B)&lt;/FONT&gt;&lt;SUP&gt;&lt;FONT color="#000000"&gt;-N&lt;/FONT&gt;&lt;/SUP&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks a lot!&lt;/P&gt;</description>
      <pubDate>Sat, 24 Mar 2018 22:08:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Formula-calculation/m-p/448457#M69598</guid>
      <dc:creator>user1</dc:creator>
      <dc:date>2018-03-24T22:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: Formula calculation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Formula-calculation/m-p/448467#M69599</link>
      <description>&lt;P&gt;Within a DATA step, and assuming you have variables A, B, and N:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;y=0;&lt;/P&gt;
&lt;P&gt;do k=1 to n;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;y + a*b**(-k);&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If B is actually an expression rather than a variable, put it in parentheses:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;y + a*(b)**(-k);&lt;/P&gt;</description>
      <pubDate>Sat, 24 Mar 2018 23:43:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Formula-calculation/m-p/448467#M69599</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-03-24T23:43:22Z</dc:date>
    </item>
    <item>
      <title>Re: Formula calculation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Formula-calculation/m-p/448474#M69600</link>
      <description>&lt;P&gt;Or this, which should be faster:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;    u = 0;
    v = 1/b;
    do k = 1 to n;
        u = (1 + u) * v;
        end;
    y = a*u;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 25 Mar 2018 03:31:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Formula-calculation/m-p/448474#M69600</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-03-25T03:31:40Z</dc:date>
    </item>
    <item>
      <title>Re: Formula calculation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Formula-calculation/m-p/448833#M69626</link>
      <description>&lt;P&gt;Thanks for you both for providing the answer, much appreciated! PG Stats, since the power is negative, should the sas code be revised?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;as &amp;nbsp;u &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;0&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; v &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;b&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do k &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; -&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt; to -&lt;SPAN class="token function"&gt;n&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; u &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;+&lt;/SPAN&gt; u&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt; v&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; end&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; y &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; a&lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;u&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;Thanks and regards.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 00:23:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Formula-calculation/m-p/448833#M69626</guid>
      <dc:creator>user1</dc:creator>
      <dc:date>2018-03-27T00:23:01Z</dc:date>
    </item>
    <item>
      <title>Re: Formula calculation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Formula-calculation/m-p/449146#M69643</link>
      <description>&lt;P&gt;No. k is only a counter, not the exponent. The exponent comes from the number of multiplications by v (= 1/b, = b**-1), i.e. the negative exponent results from multiplying by a negative power of b.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Mar 2018 20:26:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Formula-calculation/m-p/449146#M69643</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-03-27T20:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: Formula calculation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Formula-calculation/m-p/449201#M69645</link>
      <description>&lt;P&gt;Thanks again, PG Stats!!&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2018 02:33:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Formula-calculation/m-p/449201#M69645</guid>
      <dc:creator>user1</dc:creator>
      <dc:date>2018-03-28T02:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: Formula calculation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Formula-calculation/m-p/449210#M69646</link>
      <description>&lt;P&gt;Thanks! How about if N has one decimal place, e.g. 14.1?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2018 03:14:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Formula-calculation/m-p/449210#M69646</guid>
      <dc:creator>user1</dc:creator>
      <dc:date>2018-03-28T03:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: Formula calculation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Formula-calculation/m-p/449251#M69648</link>
      <description>&lt;P&gt;What is the first term in the equation if N has one decimal place?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2018 09:32:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Formula-calculation/m-p/449251#M69648</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-03-28T09:32:36Z</dc:date>
    </item>
    <item>
      <title>Re: Formula calculation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Formula-calculation/m-p/449482#M69656</link>
      <description>&lt;P&gt;In the equation, everything is the same, only if N is not an integer, the example is below and I need to calculate for each record (Y&lt;SUB&gt;&lt;FONT size="2"&gt;1&lt;/FONT&gt;&lt;/SUB&gt;........Y&lt;SUB&gt;&lt;FONT size="2"&gt;N&lt;/FONT&gt;&lt;/SUB&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Y&lt;SUB&gt;1&lt;/SUB&gt;=A*(B)&lt;SUP&gt;-1&lt;/SUP&gt;+ A*(B)&lt;SUP&gt;-2&lt;/SUP&gt; + A*(B)&lt;SUP&gt;-3&lt;/SUP&gt; + A*(B)&lt;SUP&gt;-4&lt;/SUP&gt; +……+ A*(B)&lt;SUP&gt;-10.2&lt;/SUP&gt;&lt;/P&gt;
&lt;P&gt;Y&lt;SUB&gt;2&lt;/SUB&gt;=A*(B)&lt;SUP&gt;-1&lt;/SUP&gt;+ A*(B)&lt;SUP&gt;-2&lt;/SUP&gt; + A*(B)&lt;SUP&gt;-3&lt;/SUP&gt; + A*(B)&lt;SUP&gt;-4&lt;/SUP&gt; +……+ A*(B)&lt;SUP&gt;-20.3&lt;/SUP&gt;&lt;/P&gt;
&lt;P&gt;&lt;SUP&gt;…….&lt;/SUP&gt;&lt;/P&gt;
&lt;P&gt;Y&lt;SUB&gt;N&lt;/SUB&gt;=A*(B)-1+ A*(B)-2 + A*(B)-3 + A*(B)-4 +……+ A*(B)&lt;SUP&gt;-N.5&lt;/SUP&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2018 19:56:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Formula-calculation/m-p/449482#M69656</guid>
      <dc:creator>user1</dc:creator>
      <dc:date>2018-03-28T19:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: Formula calculation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Formula-calculation/m-p/449485#M69657</link>
      <description>&lt;P&gt;Not clear. What is the term before the last?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2018 20:06:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Formula-calculation/m-p/449485#M69657</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-03-28T20:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: Formula calculation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Formula-calculation/m-p/449556#M69660</link>
      <description>&lt;P style="margin: 0in 0in 10pt;"&gt;&lt;SPAN style="color: black;"&gt;&lt;FONT face="Calibri"&gt;&lt;FONT size="3"&gt;Thanks very much, PG!&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in 0in 10pt;"&gt;&lt;SPAN style="color: black;"&gt;&lt;FONT face="Calibri"&gt;&lt;FONT size="3"&gt;the term before the last is: A*(B)&lt;/FONT&gt;&lt;SUP&gt;&lt;FONT size="2"&gt;-N+1 &lt;/FONT&gt;&lt;/SUP&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;For example,&lt;/P&gt;
&lt;P&gt;Y&lt;SUB&gt;1&lt;/SUB&gt;=A*(B)&lt;SUP&gt;-1&lt;/SUP&gt;+ A*(B)&lt;SUP&gt;-2&lt;/SUP&gt; + A*(B)&lt;SUP&gt;-3&lt;/SUP&gt; + A*(B)&lt;SUP&gt;-4&lt;/SUP&gt; +……+ A*(B)&lt;SUP&gt;-9&lt;/SUP&gt; +A*(B)&lt;SUP&gt;-10.2&lt;/SUP&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I run the above sas code, the decimal 0.2 from the last term is missing.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Mar 2018 02:31:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Formula-calculation/m-p/449556#M69660</guid>
      <dc:creator>user1</dc:creator>
      <dc:date>2018-03-29T02:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: Formula calculation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Formula-calculation/m-p/449557#M69661</link>
      <description>&lt;P&gt;sorry, it is not -N+1, it should be integer -N+1, for example if N is 10.2, then the term before the last one should be A*(B)&lt;SUP&gt;-9&lt;/SUP&gt; , not 9.2.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Mar 2018 02:35:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Formula-calculation/m-p/449557#M69661</guid>
      <dc:creator>user1</dc:creator>
      <dc:date>2018-03-29T02:35:27Z</dc:date>
    </item>
  </channel>
</rss>

