<?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: how to sum a value in row 1 with row 2 in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-sum-a-value-in-row-1-with-row-2/m-p/199693#M15085</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you were building in Enterprise Guide are you using data step (Program) or query builder?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In query builder you would write a series of 'Advanced Expressions' in the 'Computed Column' menu&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For B1 it would be a simple t1.A1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For B2 it would be sum(t1.A1,t1.A2)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For B3 it would be sum(t1.A1,t1.A2,t1.A3)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and you would need to do one computed column at a time until you have all your columns (you can press the validate button in the advanced expression menu to test that the logic is correct)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in data step it would be&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA &lt;EM&gt;test&lt;/EM&gt;; (&amp;lt;Data set you are creating)&lt;/P&gt;&lt;P&gt;SET &lt;EM&gt;question&lt;/EM&gt;; (&amp;lt;Data set you are calculating from)&lt;/P&gt;&lt;P&gt;b1=a1;&lt;/P&gt;&lt;P&gt;b2=a1+a2;&lt;/P&gt;&lt;P&gt;b3=a1+a2+a3;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 13 Mar 2015 09:19:47 GMT</pubDate>
    <dc:creator>t_kingsbury</dc:creator>
    <dc:date>2015-03-13T09:19:47Z</dc:date>
    <item>
      <title>how to sum a value in row 1 with row 2</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-sum-a-value-in-row-1-with-row-2/m-p/199682#M15074</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a table with 600 observations (rows) with a numeric value for each row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to create a new column (B) where B1 is the value in A1, B2 = A1+A2, B3 = A1+A2+A3 and so forth&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can this be done in Enterprise Guide? I have looked for it but could not find any solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not yet familiarized with SAS code but if anyone has the solútion in code I will try and use that but will be very useful if it can be done in EG1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Casper&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Mar 2015 09:53:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-sum-a-value-in-row-1-with-row-2/m-p/199682#M15074</guid>
      <dc:creator>CasperH_</dc:creator>
      <dc:date>2015-03-12T09:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a value in row 1 with row 2</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-sum-a-value-in-row-1-with-row-2/m-p/199683#M15075</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;B+A;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Mar 2015 12:42:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-sum-a-value-in-row-1-with-row-2/m-p/199683#M15075</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-03-12T12:42:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a value in row 1 with row 2</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-sum-a-value-in-row-1-with-row-2/m-p/199684#M15076</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would add that you probably want a retain on that:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;have:&lt;/P&gt;&lt;P&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;4&lt;/P&gt;&lt;P&gt;5&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;want:&lt;/P&gt;&lt;P&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/P&gt;&lt;P&gt;5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If so then:&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; retain b;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if _n_=1 then b=a;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else b=b+a;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Mar 2015 12:56:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-sum-a-value-in-row-1-with-row-2/m-p/199684#M15076</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-03-12T12:56:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a value in row 1 with row 2</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-sum-a-value-in-row-1-with-row-2/m-p/199685#M15077</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You don't need RETAIN with SUM statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The variable on the left is initialized to 0 and retained.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Mar 2015 13:39:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-sum-a-value-in-row-1-with-row-2/m-p/199685#M15077</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-03-12T13:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a value in row 1 with row 2</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-sum-a-value-in-row-1-with-row-2/m-p/199686#M15078</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry, not sure I follow you.&amp;nbsp; I was referring to the OP who put: "&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt; A1, B2 = A1+A2, B3 = A1+A2+A3 " so B in row 3 should be 1 + 4 + 5, so the value from the the last observation is added to the one on the current observation.&amp;nbsp; These two want's give different results:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; a=1; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; a=4; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; a=5; output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data want1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; b=sum(a,b);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data want2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain b;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _n_=1 then b=a;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else b=b+a;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Mar 2015 13:53:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-sum-a-value-in-row-1-with-row-2/m-p/199686#M15078</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-03-12T13:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a value in row 1 with row 2</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-sum-a-value-in-row-1-with-row-2/m-p/199687#M15079</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;RW9: I think DN was referring to the following form:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Correct but still more complex than needed:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _n_=1 then b=a;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else b+a;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Better (per data_null_'s subsequent post):&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;data want;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 13.3333330154419px; line-height: 1.5em;"&gt;b+a;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Mar 2015 14:00:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-sum-a-value-in-row-1-with-row-2/m-p/199687#M15079</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2015-03-12T14:00:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a value in row 1 with row 2</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-sum-a-value-in-row-1-with-row-2/m-p/199688#M15080</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah, ok &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Mar 2015 14:02:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-sum-a-value-in-row-1-with-row-2/m-p/199688#M15080</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-03-12T14:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a value in row 1 with row 2</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-sum-a-value-in-row-1-with-row-2/m-p/199689#M15081</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;RTM Not SUM function SUM STATEMENT. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; have;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; a=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;output&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; a=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;4&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;output&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; a=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;5&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;output&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; want1;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; have;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; b+a;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;print&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; want2;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; have;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;retain&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; b;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; _n_=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; b=a;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;else&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; b=b+a;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;print&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;IMG alt="3-12-2015 9-01-28 AM.png" class="jive-image" src="https://communities.sas.com/legacyfs/online/9540_3-12-2015 9-01-28 AM.png" /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Mar 2015 14:02:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-sum-a-value-in-row-1-with-row-2/m-p/199689#M15081</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-03-12T14:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a value in row 1 with row 2</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-sum-a-value-in-row-1-with-row-2/m-p/199690#M15082</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No I am referring to sum statement the reply from xia that RW9 is saying doesn't work.&amp;nbsp; RW9 doesn't know sum statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Mar 2015 14:05:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-sum-a-value-in-row-1-with-row-2/m-p/199690#M15082</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-03-12T14:05:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a value in row 1 with row 2</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-sum-a-value-in-row-1-with-row-2/m-p/199691#M15083</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA data1;&lt;/P&gt;&lt;P&gt;INFILE datalines;&lt;/P&gt;&lt;P&gt;INPUT A ;&lt;/P&gt;&lt;P&gt;B + A;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;8&lt;/P&gt;&lt;P&gt;10&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;7&lt;/P&gt;&lt;P&gt;12&lt;/P&gt;&lt;P&gt;4&lt;/P&gt;&lt;P&gt;9&lt;/P&gt;&lt;P&gt;15&lt;/P&gt;&lt;P&gt;10&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;;run;&lt;/P&gt;&lt;P&gt;proc print data=data1;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Mar 2015 15:00:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-sum-a-value-in-row-1-with-row-2/m-p/199691#M15083</guid>
      <dc:creator>Sangram</dc:creator>
      <dc:date>2015-03-12T15:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a value in row 1 with row 2</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-sum-a-value-in-row-1-with-row-2/m-p/199692#M15084</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you have the license for SAS ETS this is called a running sum and it should be under:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #444444; font-family: Georgia, Cambria, 'Palatino Linotype', serif; font-size: 15px; background-color: #ffffff;"&gt;Analyze -&amp;gt; Time Series -&amp;gt; Prepare Time Series Data&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #444444; font-family: Georgia, Cambria, 'Palatino Linotype', serif; font-size: 15px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #444444; font-family: Georgia, Cambria, 'Palatino Linotype', serif; font-size: 15px; background-color: #ffffff;"&gt;I think it should work even if you don't have time series data but don't have EG to actually test it with.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #444444; font-family: Georgia, Cambria, 'Palatino Linotype', serif; font-size: 15px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #444444; font-family: Georgia, Cambria, 'Palatino Linotype', serif; font-size: 15px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Mar 2015 17:08:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-sum-a-value-in-row-1-with-row-2/m-p/199692#M15084</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-03-12T17:08:14Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a value in row 1 with row 2</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-sum-a-value-in-row-1-with-row-2/m-p/199693#M15085</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you were building in Enterprise Guide are you using data step (Program) or query builder?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In query builder you would write a series of 'Advanced Expressions' in the 'Computed Column' menu&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For B1 it would be a simple t1.A1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For B2 it would be sum(t1.A1,t1.A2)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For B3 it would be sum(t1.A1,t1.A2,t1.A3)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and you would need to do one computed column at a time until you have all your columns (you can press the validate button in the advanced expression menu to test that the logic is correct)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in data step it would be&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA &lt;EM&gt;test&lt;/EM&gt;; (&amp;lt;Data set you are creating)&lt;/P&gt;&lt;P&gt;SET &lt;EM&gt;question&lt;/EM&gt;; (&amp;lt;Data set you are calculating from)&lt;/P&gt;&lt;P&gt;b1=a1;&lt;/P&gt;&lt;P&gt;b2=a1+a2;&lt;/P&gt;&lt;P&gt;b3=a1+a2+a3;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Mar 2015 09:19:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-sum-a-value-in-row-1-with-row-2/m-p/199693#M15085</guid>
      <dc:creator>t_kingsbury</dc:creator>
      <dc:date>2015-03-13T09:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a value in row 1 with row 2</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-sum-a-value-in-row-1-with-row-2/m-p/199694#M15086</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think there's a reasonable way to do it using the EG facilities. I recommend you follow the advice in the other posts to write a short SAS program to do it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Mar 2015 21:43:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-sum-a-value-in-row-1-with-row-2/m-p/199694#M15086</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2015-03-13T21:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a value in row 1 with row 2</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-sum-a-value-in-row-1-with-row-2/m-p/199695#M15087</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The query builder use SQL so in general, you cannot access the value of a previous rows as SQL does not in general terms respect a concept of data row order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now with said, might your data have some column that can be used as a unique identiifier, and might the summing be based on the order of that "unique" column... say somethig like date?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Given this assumption, you could use a self-join with an inequality and group summary.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Take for example the SASHELP.AIR table... date and total number of international miles traveled.&amp;nbsp;&amp;nbsp; Join the AIR table with itself, and modify the join operator in the TABLES window so that T1.DATE &amp;gt;= T2.DATE.&amp;nbsp; In the SELECT DATA window, add t1.DATE, t1.AIR, and sum(T2.AIR).&amp;nbsp; Edit the groups to include only T1.DATE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #000080; font-size: 12pt; font-family: Courier New;"&gt;PROC SQL;&lt;BR /&gt;&lt;/STRONG&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;CREATE&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;TABLE&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; WORK.QUERY_FOR_AIR &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;AS&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;&amp;nbsp;&amp;nbsp; SELECT&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; t1.DATE, t2.AIR,&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000; font-size: 12pt; font-family: Courier New;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* SUM_of_AIR */&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;&lt;STRONG&gt; (SUM (t2.AIR))&lt;/STRONG&gt; AS&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; SUM_of_AIR&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;&amp;nbsp;&amp;nbsp; FROM&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; SASHELP.AIR t1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;INNER&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;JOIN&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; SASHELP.AIR t2 &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;ON&lt;/SPAN&gt;&lt;STRONG style=": ; font-size: 12pt; font-family: Courier New;"&gt; (t1.DATE &amp;gt;= t2.DATE)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;GROUP&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;BY&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;&lt;STRONG&gt; t1.DATE&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Mar 2015 00:01:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-sum-a-value-in-row-1-with-row-2/m-p/199695#M15087</guid>
      <dc:creator>RogerSpeas</dc:creator>
      <dc:date>2015-03-18T00:01:06Z</dc:date>
    </item>
  </channel>
</rss>

