<?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: complex summing???? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/complex-summing/m-p/10148#M923</link>
    <description>Probably something like &lt;BR /&gt;
if code = 21.1 then depth = depth*(-1);  &lt;BR /&gt;
prior to your sum.</description>
    <pubDate>Mon, 26 Apr 2010 19:23:18 GMT</pubDate>
    <dc:creator>Flip</dc:creator>
    <dc:date>2010-04-26T19:23:18Z</dc:date>
    <item>
      <title>complex summing????</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/complex-summing/m-p/10147#M922</link>
      <description>I need to manipulate the data generated from the output that you helped with. RMS{i}=21.1 is a code associated with a negative number (i.e. - 2.75). I need to subtract that number from the codes below.&lt;BR /&gt;
&lt;BR /&gt;
Code&lt;BR /&gt;
21.1 = Milling (Always Subtracted)&lt;BR /&gt;
06 = Pavement (Always Added)&lt;BR /&gt;
08 = Pavement (Always Added)&lt;BR /&gt;
40 = Base (Ignored except when below milling)&lt;BR /&gt;
&lt;BR /&gt;
Senario 1&lt;BR /&gt;
Instance Code Depth&lt;BR /&gt;
1 21.1 -2.75 &lt;BR /&gt;
2 08 1.00 2.1=sum(1:2) -1.75&lt;BR /&gt;
3 40 1.00 3.1=sum(2.1:3) -0.75&lt;BR /&gt;
4 06 0.50 4.1=sum(3.1:4) -0.25&lt;BR /&gt;
5 08 0.75 5.1=sum(4.1:5) 0.50&lt;BR /&gt;
6 40 6.00 6.1=sum(5.1:6) 0.50&lt;BR /&gt;
7 08 2.75 7.1=sum(6.1:7) 3.25 &lt;BR /&gt;
&lt;BR /&gt;
Output = 3.50 Total Depth</description>
      <pubDate>Mon, 26 Apr 2010 17:36:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/complex-summing/m-p/10147#M922</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-04-26T17:36:48Z</dc:date>
    </item>
    <item>
      <title>Re: complex summing????</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/complex-summing/m-p/10148#M923</link>
      <description>Probably something like &lt;BR /&gt;
if code = 21.1 then depth = depth*(-1);  &lt;BR /&gt;
prior to your sum.</description>
      <pubDate>Mon, 26 Apr 2010 19:23:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/complex-summing/m-p/10148#M923</guid>
      <dc:creator>Flip</dc:creator>
      <dc:date>2010-04-26T19:23:18Z</dc:date>
    </item>
    <item>
      <title>Re: complex summing????</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/complex-summing/m-p/10149#M924</link>
      <description>That would only make the 21.1 a positve number increasing the total depth. i need to deduct 21.1 from the numbers below but once the number becomes positive then stop the sum and any codes that are a base, set them equal to zero then sum the leftover numbers from where the first sum stopped.</description>
      <pubDate>Tue, 27 Apr 2010 12:52:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/complex-summing/m-p/10149#M924</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-04-27T12:52:30Z</dc:date>
    </item>
    <item>
      <title>Re: complex summing????</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/complex-summing/m-p/10150#M925</link>
      <description>I'm afraid that I am not following the logic you are trying to describe.</description>
      <pubDate>Tue, 27 Apr 2010 13:38:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/complex-summing/m-p/10150#M925</guid>
      <dc:creator>Flip</dc:creator>
      <dc:date>2010-04-27T13:38:44Z</dc:date>
    </item>
    <item>
      <title>Re: complex summing????</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/complex-summing/m-p/10151#M926</link>
      <description>Your explanations are very obscure indeed.&lt;BR /&gt;
[pre]&lt;BR /&gt;
data SAMPLE;&lt;BR /&gt;
 infile cards missover;&lt;BR /&gt;
  do until(CODE=.);&lt;BR /&gt;
    input CODE DEPTH @;&lt;BR /&gt;
    output;&lt;BR /&gt;
  end;&lt;BR /&gt;
  input;&lt;BR /&gt;
cards;&lt;BR /&gt;
20 1.00 45 9.00 21.1 -4.75 08 1.00 06 0.50 08 1.50 &lt;BR /&gt;
20 0.75 21.1 -2.2 08 1.50 20 0.50 21.2 -2.00 08 1.25 &lt;BR /&gt;
20 0.75 21.1 -2.25 08 1.50 21.2 -2.00 08 1.25 25 9.00 &lt;BR /&gt;
21.1 -2.75 8 1 40 1 6 .5 8 .75 40 6 8 2.75 &lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data SUMS;&lt;BR /&gt;
  set SAMPLE;&lt;BR /&gt;
  if SUM &amp;lt;0 then SUM+DEPTH;          *add if negative;&lt;BR /&gt;
  else if CODE ne 40 then SUM+DEPTH; *else if positive add if not base;&lt;BR /&gt;
  if CODE=.  then SUM=.;             *reset between groups;&lt;BR /&gt;
run;&lt;BR /&gt;
.&lt;BR /&gt;
&lt;BR /&gt;
yields for the last data line:&lt;BR /&gt;
                                     CODE   DEPTH        SUM&lt;BR /&gt;
                                     21.1    -2.75     -2.75&lt;BR /&gt;
                                      8.0     1.00     -1.75&lt;BR /&gt;
                                     40.0     1.00     -0.75&lt;BR /&gt;
                                      6.0     0.50     -0.25&lt;BR /&gt;
                                      8.0     0.75      0.50&lt;BR /&gt;
                                     40.0     6.00      0.50&lt;BR /&gt;
                                      8.0     2.75      3.25&lt;BR /&gt;
 &lt;BR /&gt;
unsure how you find 3.50</description>
      <pubDate>Wed, 28 Apr 2010 21:12:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/complex-summing/m-p/10151#M926</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2010-04-28T21:12:18Z</dc:date>
    </item>
  </channel>
</rss>

