<?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: Calculate New Field in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Calculate-New-Field/m-p/51749#M14232</link>
    <description>Either your rules or example data are incorrect or don't understand what you want to accomplish.  The following comes close, but does not achieve all of the values you want.  Hopefully, you can correct it yourself:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data want (drop=last:);&lt;BR /&gt;
  set have;&lt;BR /&gt;
  array last_amt(50);&lt;BR /&gt;
  retain last:;&lt;BR /&gt;
  if id eq 0 or missing(last_amt(grp)) then new_amt=amt;&lt;BR /&gt;
  else new_amt=abs(amt-last_amt(grp));&lt;BR /&gt;
  last_amt(grp)=amt;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Art</description>
    <pubDate>Sat, 16 Apr 2011 22:01:39 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2011-04-16T22:01:39Z</dc:date>
    <item>
      <title>Calculate New Field</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculate-New-Field/m-p/51748#M14231</link>
      <description>I have ID, GRP and AMT fields.  Basically, what I want to calculate NEW_AMT field.&lt;BR /&gt;
&lt;BR /&gt;
(A) When ID=0, the NEW_AMT field should be the same as AMT.&lt;BR /&gt;
&lt;BR /&gt;
 &lt;BR /&gt;
(B) For ID&amp;gt;0, WITHIN EACH ID, SUBTRACT AMT FOR EACH GRP FROM THE PREVIOUS GRP.&lt;BR /&gt;
    IF PREVIOUS GRP DOES NOT EXIST THEN AMT = NEW_AMT.&lt;BR /&gt;
    &lt;BR /&gt;
(C) If there is no  AMT entry for the previous GRP&lt;BR /&gt;
    Then, NEW_AMT would be the same as AMT.&lt;BR /&gt;
&lt;BR /&gt;
(D) ID &amp;amp;/or GRP can take vaule upto 50.&lt;BR /&gt;
&lt;BR /&gt;
Thanks for your help &lt;BR /&gt;
&lt;BR /&gt;
&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&lt;BR /&gt;
&lt;BR /&gt;
ID  GRP  AMT  NEW_AMT&lt;BR /&gt;
&lt;BR /&gt;
0    1   10    10&lt;BR /&gt;
0    2   20    20&lt;BR /&gt;
&lt;BR /&gt;
1    1   10    10-10=0&lt;BR /&gt;
1    2   20    20-20=0&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
2    1   25    25-10 =15&lt;BR /&gt;
2    2   50    50-20 =30&lt;BR /&gt;
2    3   75    75-0  =75   &lt;BR /&gt;
2    3   100   100-0= 100&lt;BR /&gt;
&lt;BR /&gt;
3    1   51    51-25= 26&lt;BR /&gt;
3    2   61    61-50=11&lt;BR /&gt;
3    3   71    71-75=-4&lt;BR /&gt;
3    3   81    81-100 =-19&lt;BR /&gt;
3    4   91    91-0=91&lt;BR /&gt;
&lt;BR /&gt;
4    1   20    20-51=-31&lt;BR /&gt;
4    2   40    40-61=-21&lt;BR /&gt;
4    3   60    60-71=-11&lt;BR /&gt;
4    3   80    80-81=-1&lt;BR /&gt;
4    4   100   100-91=9&lt;BR /&gt;
4    5   120   120-0=0&lt;BR /&gt;
4    6   140   140-0=0&lt;BR /&gt;
&lt;BR /&gt;
..........&lt;BR /&gt;
..........&lt;BR /&gt;
..........</description>
      <pubDate>Sat, 16 Apr 2011 20:58:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculate-New-Field/m-p/51748#M14231</guid>
      <dc:creator>GPatel</dc:creator>
      <dc:date>2011-04-16T20:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate New Field</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculate-New-Field/m-p/51749#M14232</link>
      <description>Either your rules or example data are incorrect or don't understand what you want to accomplish.  The following comes close, but does not achieve all of the values you want.  Hopefully, you can correct it yourself:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data want (drop=last:);&lt;BR /&gt;
  set have;&lt;BR /&gt;
  array last_amt(50);&lt;BR /&gt;
  retain last:;&lt;BR /&gt;
  if id eq 0 or missing(last_amt(grp)) then new_amt=amt;&lt;BR /&gt;
  else new_amt=abs(amt-last_amt(grp));&lt;BR /&gt;
  last_amt(grp)=amt;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Art</description>
      <pubDate>Sat, 16 Apr 2011 22:01:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculate-New-Field/m-p/51749#M14232</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-04-16T22:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate New Field</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculate-New-Field/m-p/51750#M14233</link>
      <description>ART:&lt;BR /&gt;
Thanks for your time and sharing your solution to my post.&lt;BR /&gt;
 &lt;BR /&gt;
Here is SAS pgm. I ran and output is displayed below.&lt;BR /&gt;
&lt;BR /&gt;
data one;&lt;BR /&gt;
input ID GRP AMT  ;&lt;BR /&gt;
cards;&lt;BR /&gt;
0 1 10  &lt;BR /&gt;
0 2 20 &lt;BR /&gt;
1 1 10  &lt;BR /&gt;
1 2 20&lt;BR /&gt;
2 1 25  &lt;BR /&gt;
2 2 50  &lt;BR /&gt;
2 3 75  &lt;BR /&gt;
2 3 100&lt;BR /&gt;
3 1 51  &lt;BR /&gt;
3 2 61  &lt;BR /&gt;
3 3 71  &lt;BR /&gt;
3 3 81  &lt;BR /&gt;
3 4 91&lt;BR /&gt;
4 1 20  &lt;BR /&gt;
4 2 40  &lt;BR /&gt;
4 3 60  &lt;BR /&gt;
4 3 80  &lt;BR /&gt;
4 4 100  &lt;BR /&gt;
4 5 120  &lt;BR /&gt;
4 6 140  &lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
data want (drop=last:);&lt;BR /&gt;
set one;&lt;BR /&gt;
array last_amt(50);&lt;BR /&gt;
retain last:;&lt;BR /&gt;
if id eq 0 or missing(last_amt(grp)) then new_amt=amt;&lt;BR /&gt;
else new_amt=abs(amt-last_amt(grp));&lt;BR /&gt;
last_amt(grp)=amt;&lt;BR /&gt;
run;                        &lt;BR /&gt;
                 &lt;BR /&gt;
&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; OUTPUT&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&lt;BR /&gt;
  &lt;BR /&gt;
                            Obs    ID    GRP  AMT  new_amt&lt;BR /&gt;
&lt;BR /&gt;
                                 1     0     1      10       10&lt;BR /&gt;
                                 2     0     2      20       20&lt;BR /&gt;
                                 3     1     1      10        0&lt;BR /&gt;
                                 4     1     2      20        0&lt;BR /&gt;
                                 5     2     1      25       15&lt;BR /&gt;
                                 6     2     2      50       30&lt;BR /&gt;
                                 7     2     3      75       75&lt;BR /&gt;
                                 8     2     3     100       25&lt;BR /&gt;
                                 9     3     1      51       26&lt;BR /&gt;
                                10     3     2      61       11&lt;BR /&gt;
                                11     3     3      71       29&lt;BR /&gt;
                                12     3     3      81       10&lt;BR /&gt;
                                13     3     4      91       91&lt;BR /&gt;
                                14     4     1      20       31&lt;BR /&gt;
                                15     4     2      40       21&lt;BR /&gt;
                                16     4     3      60       21&lt;BR /&gt;
                                17     4     3      80       20&lt;BR /&gt;
                                18     4     4     100        9&lt;BR /&gt;
                                19     4     5     120      120&lt;BR /&gt;
                                20     4     6     140      140&lt;BR /&gt;
.........&lt;BR /&gt;
&lt;BR /&gt;
For record # 7, it correctly calculated NEW_AMT. We are substracting 75(ID=2,GRP=3) minus 0( there is no ID=1 and GRP=3).&lt;BR /&gt;
&lt;BR /&gt;
For record # 8, NEW_AMT should be 100. We are subtracting 100(ID=2,GRP=3) minus 0(there is no ID=1 and GRP=3).&lt;BR /&gt;
&lt;BR /&gt;
For record # 11, NEW_AMT should be -4. We are subtracting 71( where ID=3 &amp;amp; GRP=3) from 75 (where ID=2 and GRP=3).&lt;BR /&gt;
&lt;BR /&gt;
For record # 12, NEW_AMT should be -19. We are subtracting 81( where ID=3 &amp;amp; GRP=3) from 100 (where ID=2 and GRP=3).&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
For record # 13, it calculated correclty NEW_AMT=91.  &lt;BR /&gt;
&lt;BR /&gt;
For record # 14, NEW_AMT should be -31. We are subtracting 20( where ID=4 &amp;amp; GRP=1) from 51 (where ID=3 and GRP=1).&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
For record # 15, NEW_AMT should be -21. We are subtracting 40( where ID=4 &amp;amp; GRP=2) from 61 (where ID=3 and GRP=2).&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
For record # 16, NEW_AMT should be -11. We are subtracting 60( where ID=4 &amp;amp; GRP=3) from 71 (where ID=3 and GRP=3).&lt;BR /&gt;
&lt;BR /&gt;
For record # 17, NEW_AMT should be -1. We are subtracting 80( where ID=4 &amp;amp; GRP=3) from 81 (where ID=3 and GRP=3).&lt;BR /&gt;
&lt;BR /&gt;
For record # 18, calculated NEW_AMT is correct.&lt;BR /&gt;
 &lt;BR /&gt;
In nut shell, the rule is &lt;BR /&gt;
For ID &amp;gt; 0,&lt;BR /&gt;
SUBTRACT VALUE OF GIVEN (ID,GRP)  MINUS VALU EOF PREVIOUS (ID,GRP).&lt;BR /&gt;
&lt;BR /&gt;
If for the current record, for the given value of  (ID,GRP), if previous value of (ID,GRP) doesn't exist, then for the current record, new_amt should be the same as amt.&lt;BR /&gt;
&lt;BR /&gt;
I hope this explains rules. &lt;BR /&gt;
&lt;BR /&gt;
Thanks for your assistance.</description>
      <pubDate>Sun, 17 Apr 2011 00:49:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculate-New-Field/m-p/51750#M14233</guid>
      <dc:creator>GPatel</dc:creator>
      <dc:date>2011-04-17T00:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate New Field</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculate-New-Field/m-p/51751#M14234</link>
      <description>If the values for records 19 and 20 really should be 120 and 140, then the following might do what you want to accomplish:&lt;BR /&gt;
&lt;BR /&gt;
data want (drop=last:);&lt;BR /&gt;
  set have;&lt;BR /&gt;
  array last_amt(50,50);&lt;BR /&gt;
  retain last:;&lt;BR /&gt;
  by id grp;&lt;BR /&gt;
  if first.grp then within_grp=1;&lt;BR /&gt;
  else within_grp+1;&lt;BR /&gt;
  if id eq 0 or missing(last_amt(grp,within_grp)) then new_amt=amt;&lt;BR /&gt;
  else new_amt=amt-last_amt(grp,within_grp);&lt;BR /&gt;
  last_amt(grp,within_grp)=amt;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
HTH,&lt;BR /&gt;
Art&lt;BR /&gt;
--------&lt;BR /&gt;
&amp;gt; ART:&lt;BR /&gt;
&amp;gt; Thanks for your time and sharing your solution to my&lt;BR /&gt;
&amp;gt; post.&lt;BR /&gt;
&amp;gt;  &lt;BR /&gt;
&amp;gt; ere is SAS pgm. I ran and output is displayed below.&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; data one;&lt;BR /&gt;
&amp;gt; input ID GRP AMT  ;&lt;BR /&gt;
&amp;gt; cards;&lt;BR /&gt;
&amp;gt; 0 1 10  &lt;BR /&gt;
&amp;gt; 0 2 20 &lt;BR /&gt;
&amp;gt; 1 1 10  &lt;BR /&gt;
&amp;gt; 1 2 20&lt;BR /&gt;
&amp;gt; 2 1 25  &lt;BR /&gt;
&amp;gt; 2 2 50  &lt;BR /&gt;
&amp;gt; 2 3 75  &lt;BR /&gt;
&amp;gt; 2 3 100&lt;BR /&gt;
&amp;gt; 3 1 51  &lt;BR /&gt;
&amp;gt; 3 2 61  &lt;BR /&gt;
&amp;gt; 3 3 71  &lt;BR /&gt;
&amp;gt; 3 3 81  &lt;BR /&gt;
&amp;gt; 3 4 91&lt;BR /&gt;
&amp;gt; 4 1 20  &lt;BR /&gt;
&amp;gt; 4 2 40  &lt;BR /&gt;
&amp;gt; 4 3 60  &lt;BR /&gt;
&amp;gt; 4 3 80  &lt;BR /&gt;
&amp;gt; 4 4 100  &lt;BR /&gt;
&amp;gt; 4 5 120  &lt;BR /&gt;
&amp;gt; 4 6 140  &lt;BR /&gt;
&amp;gt; ;&lt;BR /&gt;
&amp;gt; run;&lt;BR /&gt;
&amp;gt; data want (drop=last:);&lt;BR /&gt;
&amp;gt; set one;&lt;BR /&gt;
&amp;gt; array last_amt(50);&lt;BR /&gt;
&amp;gt; retain last:;&lt;BR /&gt;
&amp;gt; if id eq 0 or missing(last_amt(grp)) then&lt;BR /&gt;
&amp;gt; new_amt=amt;&lt;BR /&gt;
&amp;gt; else new_amt=abs(amt-last_amt(grp));&lt;BR /&gt;
&amp;gt; last_amt(grp)=amt;&lt;BR /&gt;
&amp;gt; run;                        &lt;BR /&gt;
&amp;gt;                  &lt;BR /&gt;
&amp;gt; &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&lt;BR /&gt;
&amp;gt;   &lt;BR /&gt;
&amp;gt; Obs    ID    GRP  AMT&lt;BR /&gt;
&amp;gt;  new_amt&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; 1     0     1&lt;BR /&gt;
&amp;gt;      10       10&lt;BR /&gt;
&amp;gt; 2     0     2      20&lt;BR /&gt;
&amp;gt;       20&lt;BR /&gt;
&amp;gt; 3     1     1      10&lt;BR /&gt;
&amp;gt;        0&lt;BR /&gt;
&amp;gt; 4     1     2      20&lt;BR /&gt;
&amp;gt;        0&lt;BR /&gt;
&amp;gt; 5     2     1      25&lt;BR /&gt;
&amp;gt;       15&lt;BR /&gt;
&amp;gt; 6     2     2      50&lt;BR /&gt;
&amp;gt;       30&lt;BR /&gt;
&amp;gt; 7     2     3      75&lt;BR /&gt;
&amp;gt;       75&lt;BR /&gt;
&amp;gt; 8     2     3     100&lt;BR /&gt;
&amp;gt;       25&lt;BR /&gt;
&amp;gt; 9     3     1      51&lt;BR /&gt;
&amp;gt;       26&lt;BR /&gt;
&amp;gt; 10     3     2      61&lt;BR /&gt;
&amp;gt;       11&lt;BR /&gt;
&amp;gt; 11     3     3      71&lt;BR /&gt;
&amp;gt;       29&lt;BR /&gt;
&amp;gt; 12     3     3      81&lt;BR /&gt;
&amp;gt;       10&lt;BR /&gt;
&amp;gt; 13     3     4      91&lt;BR /&gt;
&amp;gt;       91&lt;BR /&gt;
&amp;gt; 14     4     1      20&lt;BR /&gt;
&amp;gt;       31&lt;BR /&gt;
&amp;gt; 15     4     2      40&lt;BR /&gt;
&amp;gt;       21&lt;BR /&gt;
&amp;gt; 16     4     3      60&lt;BR /&gt;
&amp;gt;       21&lt;BR /&gt;
&amp;gt; 17     4     3      80&lt;BR /&gt;
&amp;gt;       20&lt;BR /&gt;
&amp;gt; 18     4     4     100&lt;BR /&gt;
&amp;gt;        9&lt;BR /&gt;
&amp;gt; 19     4     5     120&lt;BR /&gt;
&amp;gt;      120&lt;BR /&gt;
&amp;gt; 20     4     6     140&lt;BR /&gt;
&amp;gt;      140&lt;BR /&gt;
&amp;gt; ....&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; For record # 7, it correctly calculated NEW_AMT. We&lt;BR /&gt;
&amp;gt; are substracting 75(ID=2,GRP=3) minus 0( there is no&lt;BR /&gt;
&amp;gt; ID=1 and GRP=3).&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; For record # 8, NEW_AMT should be 100. We are&lt;BR /&gt;
&amp;gt; subtracting 100(ID=2,GRP=3) minus 0(there is no ID=1&lt;BR /&gt;
&amp;gt; and GRP=3).&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; For record # 11, NEW_AMT should be -4. We are&lt;BR /&gt;
&amp;gt; subtracting 71( where ID=3 &amp;amp; GRP=3) from 75 (where&lt;BR /&gt;
&amp;gt; ID=2 and GRP=3).&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; For record # 12, NEW_AMT should be -19. We are&lt;BR /&gt;
&amp;gt; subtracting 81( where ID=3 &amp;amp; GRP=3) from 100 (where&lt;BR /&gt;
&amp;gt; ID=2 and GRP=3).&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; For record # 13, it calculated correclty NEW_AMT=91.&lt;BR /&gt;
&amp;gt;  &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; For record # 14, NEW_AMT should be -31. We are&lt;BR /&gt;
&amp;gt; subtracting 20( where ID=4 &amp;amp; GRP=1) from 51 (where&lt;BR /&gt;
&amp;gt; ID=3 and GRP=1).&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; For record # 15, NEW_AMT should be -21. We are&lt;BR /&gt;
&amp;gt; subtracting 40( where ID=4 &amp;amp; GRP=2) from 61 (where&lt;BR /&gt;
&amp;gt; ID=3 and GRP=2).&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; For record # 16, NEW_AMT should be -11. We are&lt;BR /&gt;
&amp;gt; subtracting 60( where ID=4 &amp;amp; GRP=3) from 71 (where&lt;BR /&gt;
&amp;gt; ID=3 and GRP=3).&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; For record # 17, NEW_AMT should be -1. We are&lt;BR /&gt;
&amp;gt; subtracting 80( where ID=4 &amp;amp; GRP=3) from 81 (where&lt;BR /&gt;
&amp;gt; ID=3 and GRP=3).&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; For record # 18, calculated NEW_AMT is correct.&lt;BR /&gt;
&amp;gt;  &lt;BR /&gt;
&amp;gt; n nut shell, the rule is &lt;BR /&gt;
&amp;gt; For ID &amp;gt; 0,&lt;BR /&gt;
&amp;gt; SUBTRACT VALUE OF GIVEN (ID,GRP)  MINUS VALU EOF&lt;BR /&gt;
&amp;gt; PREVIOUS (ID,GRP).&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; If for the current record, for the given value of&lt;BR /&gt;
&amp;gt; (ID,GRP), if previous value of (ID,GRP) doesn't&lt;BR /&gt;
&amp;gt; exist, then for the current record, new_amt should&lt;BR /&gt;
&amp;gt;  be the same as amt.&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; I hope this explains rules. &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; Thanks for your assistance.</description>
      <pubDate>Sun, 17 Apr 2011 14:15:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculate-New-Field/m-p/51751#M14234</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-04-17T14:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate New Field</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculate-New-Field/m-p/51752#M14235</link>
      <description>Art,&lt;BR /&gt;
&lt;BR /&gt;
It worked like a charm. Thanks for your prompt and perfect solution. Can you please explain me the logic "  last_amt(grp,witin_grp) " ?&lt;BR /&gt;
&lt;BR /&gt;
I never encountered such a ...........&lt;BR /&gt;
&lt;BR /&gt;
Again thanks a lot.&lt;BR /&gt;
&lt;BR /&gt;
GPatel</description>
      <pubDate>Sun, 17 Apr 2011 22:40:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculate-New-Field/m-p/51752#M14235</guid>
      <dc:creator>GPatel</dc:creator>
      <dc:date>2011-04-17T22:40:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate New Field</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Calculate-New-Field/m-p/51753#M14236</link>
      <description>&amp;gt;Can you please explain me the logic "last_amt(grp,witin_grp) " ?&lt;BR /&gt;
&lt;BR /&gt;
Arrays can be multidimensional.  As such, since your desired logic required looking at the last value held in the same position, I simply created a 50x50 matrix and accessed the value at the required position.&lt;BR /&gt;
&lt;BR /&gt;
Art</description>
      <pubDate>Sun, 17 Apr 2011 23:41:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Calculate-New-Field/m-p/51753#M14236</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-04-17T23:41:17Z</dc:date>
    </item>
  </channel>
</rss>

