<?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: sum calculation from an equation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/sum-calculation-from-an-equation/m-p/276662#M55461</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats﻿&lt;/a&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh﻿&lt;/a&gt;&lt;/P&gt;&lt;P&gt;Hello PGStats;&lt;/P&gt;&lt;P&gt;do you explain me please the utility of using a proc fcmp, while the concept proposed by @FreelanceReinhard renders results numerically equal.&lt;BR /&gt;What is the difference.&lt;/P&gt;&lt;P&gt;Thank you for your help.&lt;/P&gt;</description>
    <pubDate>Sat, 11 Jun 2016 08:48:25 GMT</pubDate>
    <dc:creator>soumri</dc:creator>
    <dc:date>2016-06-11T08:48:25Z</dc:date>
    <item>
      <title>sum calculation from an equation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sum-calculation-from-an-equation/m-p/276303#M55342</link>
      <description>&lt;P&gt;Hello;&lt;/P&gt;&lt;P&gt;I have the incomplete gamma function (IGF) which is:&lt;/P&gt;&lt;P&gt;Y = a * (t ** b) * exp (-c * t)&lt;/P&gt;&lt;P&gt;and a data like this:&lt;/P&gt;&lt;P&gt;id &amp;nbsp; &amp;nbsp; a &amp;nbsp; &amp;nbsp; &amp;nbsp;b &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;c&lt;/P&gt;&lt;P&gt;what I am looking for is to calculate P150 &amp;nbsp;which is&amp;nbsp;the sum of Yt &amp;nbsp;from t=1 to t=150&lt;/P&gt;&lt;P&gt;using params a b and c and get this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id &amp;nbsp; &amp;nbsp; &amp;nbsp;a &amp;nbsp; &amp;nbsp; &amp;nbsp;b &amp;nbsp; &amp;nbsp; &amp;nbsp; c &amp;nbsp; &amp;nbsp; &amp;nbsp; P150&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is there a method, with SAS, which allows me to do this&amp;nbsp;without using Excel (which I often do).&lt;/P&gt;&lt;P&gt;I always found help in this forum.&amp;nbsp;Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jun 2016 16:15:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sum-calculation-from-an-equation/m-p/276303#M55342</guid>
      <dc:creator>soumri</dc:creator>
      <dc:date>2016-06-09T16:15:42Z</dc:date>
    </item>
    <item>
      <title>Re: sum calculation from an equation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sum-calculation-from-an-equation/m-p/276336#M55349</link>
      <description>&lt;P&gt;Assuming the sum is over integer values of t :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc fcmp outlib=sasuser.fcmp.math;
function P150(a, b, c);
do t = 1 to 150;
    r + a * (t ** b) * exp (-c * t);
    end;
return (r);
endsub;
run;

options cmplib=sasuser.fcmp;

data _null_;
a = 1; b = 2; c = 3;
y = P150(a, b, c);
put _all_;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jun 2016 18:26:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sum-calculation-from-an-equation/m-p/276336#M55349</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-06-09T18:26:21Z</dc:date>
    </item>
    <item>
      <title>Re: sum calculation from an equation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sum-calculation-from-an-equation/m-p/276433#M55378</link>
      <description>&lt;P&gt;Thank you for your reponce PG,&lt;/P&gt;&lt;P&gt;Sorry, I think that the SAS version that I have (9.0) does not include the procedure FCMP&lt;BR /&gt;and Second, you set the values of a, b and c where as in my data file these values&amp;nbsp;&amp;nbsp;change from one line to another.&lt;/P&gt;&lt;P&gt;this is how my file looks:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;id&lt;/TD&gt;&lt;TD&gt;a&lt;/TD&gt;&lt;TD&gt;b&lt;/TD&gt;&lt;TD&gt;c&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;T0600021251&lt;/TD&gt;&lt;TD&gt;16.79361&lt;/TD&gt;&lt;TD&gt;0.04351&lt;/TD&gt;&lt;TD&gt;0.00253&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;T2100050954&lt;/TD&gt;&lt;TD&gt;10.62616&lt;/TD&gt;&lt;TD&gt;0.24511&lt;/TD&gt;&lt;TD&gt;0.00231&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;T2100071545&lt;/TD&gt;&lt;TD&gt;12.54940&lt;/TD&gt;&lt;TD&gt;0.21685&lt;/TD&gt;&lt;TD&gt;0.00301&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;T2300051246&lt;/TD&gt;&lt;TD&gt;15.35562&lt;/TD&gt;&lt;TD&gt;0.15303&lt;/TD&gt;&lt;TD&gt;0.00306&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;T2300051372&lt;/TD&gt;&lt;TD&gt;21.58488&lt;/TD&gt;&lt;TD&gt;0.05164&lt;/TD&gt;&lt;TD&gt;0.00168&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;T2300051449&lt;/TD&gt;&lt;TD&gt;24.43391&lt;/TD&gt;&lt;TD&gt;0.00001&lt;/TD&gt;&lt;TD&gt;0.00269&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;T2300051462&lt;/TD&gt;&lt;TD&gt;14.47446&lt;/TD&gt;&lt;TD&gt;0.18741&lt;/TD&gt;&lt;TD&gt;0.00365&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;T2300051496&lt;/TD&gt;&lt;TD&gt;32.75656&lt;/TD&gt;&lt;TD&gt;0.00001&lt;/TD&gt;&lt;TD&gt;0.00236&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;T2300051533&lt;/TD&gt;&lt;TD&gt;19.42636&lt;/TD&gt;&lt;TD&gt;0.00001&lt;/TD&gt;&lt;TD&gt;0.00212&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;T2300051540&lt;/TD&gt;&lt;TD&gt;20.75340&lt;/TD&gt;&lt;TD&gt;0.04351&lt;/TD&gt;&lt;TD&gt;0.00229&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;T2300051622&lt;/TD&gt;&lt;TD&gt;8.27472&lt;/TD&gt;&lt;TD&gt;0.25447&lt;/TD&gt;&lt;TD&gt;0.00237&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;T2300051655&lt;/TD&gt;&lt;TD&gt;7.73511&lt;/TD&gt;&lt;TD&gt;0.31439&lt;/TD&gt;&lt;TD&gt;0.00418&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;T2300051846&lt;/TD&gt;&lt;TD&gt;8.87238&lt;/TD&gt;&lt;TD&gt;0.26569&lt;/TD&gt;&lt;TD&gt;0.00306&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;T2300051849&lt;/TD&gt;&lt;TD&gt;26.85240&lt;/TD&gt;&lt;TD&gt;0.00001&lt;/TD&gt;&lt;TD&gt;0.00127&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;T2300056142&lt;/TD&gt;&lt;TD&gt;10.45094&lt;/TD&gt;&lt;TD&gt;0.32418&lt;/TD&gt;&lt;TD&gt;0.00475&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;T2300057352&lt;/TD&gt;&lt;TD&gt;22.15670&lt;/TD&gt;&lt;TD&gt;0.03133&lt;/TD&gt;&lt;TD&gt;0.00310&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;T2300058009&lt;/TD&gt;&lt;TD&gt;15.46157&lt;/TD&gt;&lt;TD&gt;0.12580&lt;/TD&gt;&lt;TD&gt;0.00212&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;…&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;30588 different id.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2016 07:16:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sum-calculation-from-an-equation/m-p/276433#M55378</guid>
      <dc:creator>soumri</dc:creator>
      <dc:date>2016-06-10T07:16:22Z</dc:date>
    </item>
    <item>
      <title>Re: sum calculation from an equation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sum-calculation-from-an-equation/m-p/276520#M55405</link>
      <description>&lt;P&gt;Time to upgrade! Once a function is defined with FCMP, it can be used in great many places, including, for example, in SQL&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data myData;
input id :$12.	a	b	c;
datalines;
T0600021251	16.79361	0.04351	0.00253
T2100050954	10.62616	0.24511	0.00231
T2100071545	12.54940	0.21685	0.00301
T2300051246	15.35562	0.15303	0.00306
T2300051372	21.58488	0.05164	0.00168
T2300051449	24.43391	0.00001	0.00269
T2300051462	14.47446	0.18741	0.00365
T2300051496	32.75656	0.00001	0.00236
T2300051533	19.42636	0.00001	0.00212
T2300051540	20.75340	0.04351	0.00229
T2300051622	8.27472	0.25447	0.00237
T2300051655	7.73511	0.31439	0.00418
T2300051846	8.87238	0.26569	0.00306
T2300051849	26.85240	0.00001	0.00127
T2300056142	10.45094	0.32418	0.00475
T2300057352	22.15670	0.03133	0.00310
T2300058009	15.46157	0.12580	0.00212
;

proc fcmp outlib=sasuser.fcmp.math;
function P150(a, b, c);
do t = 1 to 150;
    r + a * (t ** b) * exp (-c * t);
    end;
return (r);
endsub;
run;

options cmplib=sasuser.fcmp;

proc sql;
select *, P150(a, b, c) as d
from myData;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;                id                   a         b         c         d
                T0600021251   16.79361   0.04351   0.00253  2487.253
                T2100050954   10.62616   0.24511   0.00231   3633.33
                T2100071545    12.5494   0.21685   0.00301  3614.663
                T2300051246   15.35562   0.15303   0.00306  3396.119
                T2300051372   21.58488   0.05164   0.00168  3514.853
                T2300051449   24.43391   0.00001   0.00269  3011.899
                T2300051462   14.47446   0.18741   0.00365  3520.605
                T2300051496   32.75656   0.00001   0.00236  4133.227
                T2300051533   19.42636   0.00001   0.00212  2493.532
                T2300051540    20.7534   0.04351   0.00229  3127.748
                T2300051622    8.27472   0.25447   0.00237  2927.307
                T2300051655    7.73511   0.31439   0.00418  3039.666
                T2300051846    8.87238   0.26569   0.00306  3113.042
                T2300051849    26.8524   0.00001   0.00127  3665.269
                T2300056142   10.45094   0.32418   0.00475  4090.179
                T2300057352    22.1567   0.03133    0.0031  3001.778
                T2300058009   15.46157    0.1258   0.00212  3287.251
&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Jun 2016 15:16:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sum-calculation-from-an-equation/m-p/276520#M55405</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-06-10T15:16:45Z</dc:date>
    </item>
    <item>
      <title>Re: sum calculation from an equation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sum-calculation-from-an-equation/m-p/276628#M55447</link>
      <description>&lt;P&gt;Yes PG Stats, sure, I should do it &lt;img id="smileyvery-happy" class="emoticon emoticon-smileyvery-happy" src="https://communities.sas.com/i/smilies/16x16_smiley-very-happy.png" alt="Smiley Very Happy" title="Smiley Very Happy" /&gt;, when strong people like you offered me some great solutions to my problems. thank you so much. Just an explanation, for people who are interested to my question; This solution is interesting for the calculation of the cumulative amount that changes with time. in my case I use it to calculate the amount of milk production at different date using the wood or Wilmink function.&lt;/P&gt;&lt;P&gt;thank you again PG stats, and good luck readers.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2016 22:10:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sum-calculation-from-an-equation/m-p/276628#M55447</guid>
      <dc:creator>soumri</dc:creator>
      <dc:date>2016-06-10T22:10:32Z</dc:date>
    </item>
    <item>
      <title>Re: sum calculation from an equation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sum-calculation-from-an-equation/m-p/276632#M55449</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/87866"&gt;@soumri﻿&lt;/a&gt;: Thanks for pointing out the application area.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you don't have PROC FCMP at your disposal (yet), you can simply copy the DO loop from PG's PROC FCMP step into his data step after the INPUT statement and an additional assignment statement &lt;FONT face="courier new,courier"&gt;r=0;&lt;/FONT&gt; (to initialize variable &lt;FONT face="courier new,courier"&gt;r&lt;/FONT&gt;, which is automatically retained due to the sum statement).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2016 22:50:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sum-calculation-from-an-equation/m-p/276632#M55449</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-06-10T22:50:15Z</dc:date>
    </item>
    <item>
      <title>Re: sum calculation from an equation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sum-calculation-from-an-equation/m-p/276635#M55450</link>
      <description>&lt;P&gt;&lt;SPAN class="login-bold"&gt;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733" target="_self"&gt;@FreelanceReinhard&lt;/A&gt; Yes, it's true,&amp;nbsp;it works correctly.&amp;nbsp;thank you very much very nice to participate.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2016 23:48:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sum-calculation-from-an-equation/m-p/276635#M55450</guid>
      <dc:creator>soumri</dc:creator>
      <dc:date>2016-06-10T23:48:10Z</dc:date>
    </item>
    <item>
      <title>Re: sum calculation from an equation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sum-calculation-from-an-equation/m-p/276636#M55451</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;set have;
r=0;
do t = 1 to 150;
r + al * (t ** bl) * exp (-cl * t);
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;it's ok&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2016 23:52:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sum-calculation-from-an-equation/m-p/276636#M55451</guid>
      <dc:creator>soumri</dc:creator>
      <dc:date>2016-06-10T23:52:08Z</dc:date>
    </item>
    <item>
      <title>Re: sum calculation from an equation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sum-calculation-from-an-equation/m-p/276662#M55461</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats﻿&lt;/a&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh﻿&lt;/a&gt;&lt;/P&gt;&lt;P&gt;Hello PGStats;&lt;/P&gt;&lt;P&gt;do you explain me please the utility of using a proc fcmp, while the concept proposed by @FreelanceReinhard renders results numerically equal.&lt;BR /&gt;What is the difference.&lt;/P&gt;&lt;P&gt;Thank you for your help.&lt;/P&gt;</description>
      <pubDate>Sat, 11 Jun 2016 08:48:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sum-calculation-from-an-equation/m-p/276662#M55461</guid>
      <dc:creator>soumri</dc:creator>
      <dc:date>2016-06-11T08:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: sum calculation from an equation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sum-calculation-from-an-equation/m-p/276717#M55474</link>
      <description>&lt;P&gt;I think, PG has already mentioned the key benefit of the FCMP approach when he wrote: "Once a function is defined with FCMP, it can be used in great many places, including, for example, in SQL".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Indeed, you can call the function, across programs, in a data step without copying or remembering the formula and without the risk of name conflicts between variables used in the function definition and other data step variables.&amp;nbsp;Moreover, you can call it in places where it would be impossible to paste the defining SAS code, e.g. in WHERE conditions (in both DATA and PROC steps as well as dataset options), nested with other functions, in a macro context (via %SYSFUNC), a format definition (with SAS 9.3 or higher) or in PROC SQL, as has been demonstrated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The numerical results are equal to those from the data step DO loop.&lt;/P&gt;</description>
      <pubDate>Sat, 11 Jun 2016 22:00:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sum-calculation-from-an-equation/m-p/276717#M55474</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-06-11T22:00:40Z</dc:date>
    </item>
  </channel>
</rss>

