<?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 How to sum across in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-sum-across/m-p/356087#M64233</link>
    <description>&lt;P&gt;How i need to sum first column with another column across?&lt;/P&gt;&lt;P&gt;i mean this:&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8713i12646A642C2E11A5/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="Untitled.png" title="Untitled.png" /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data stock;
input Astock  Bstock;
cards;
500 250
200 658
300 425
400 125
;
run;

data sum;
set stock;
sum=sum(Astock,Bstock);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;How i need to change it ?&lt;/P&gt;</description>
    <pubDate>Thu, 04 May 2017 19:39:51 GMT</pubDate>
    <dc:creator>Sizzen</dc:creator>
    <dc:date>2017-05-04T19:39:51Z</dc:date>
    <item>
      <title>How to sum across</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-sum-across/m-p/356087#M64233</link>
      <description>&lt;P&gt;How i need to sum first column with another column across?&lt;/P&gt;&lt;P&gt;i mean this:&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8713i12646A642C2E11A5/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="Untitled.png" title="Untitled.png" /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data stock;
input Astock  Bstock;
cards;
500 250
200 658
300 425
400 125
;
run;

data sum;
set stock;
sum=sum(Astock,Bstock);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;How i need to change it ?&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2017 19:39:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-sum-across/m-p/356087#M64233</guid>
      <dc:creator>Sizzen</dc:creator>
      <dc:date>2017-05-04T19:39:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum across</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-sum-across/m-p/356091#M64234</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data stock;
input Astock  Bstock;
cards;
500 250
200 658
300 425
400 125
;
run;

data want;
   set stock;

   lag_Astock = lag1(Astock);
   if not missing(lag_Astock) then total = sum(Bstock,lag_Astock);

   drop lag_Astock;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 May 2017 19:44:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-sum-across/m-p/356091#M64234</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-05-04T19:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum across</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-sum-across/m-p/356095#M64235</link>
      <description>Thanks !!</description>
      <pubDate>Thu, 04 May 2017 19:54:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-sum-across/m-p/356095#M64235</guid>
      <dc:creator>Sizzen</dc:creator>
      <dc:date>2017-05-04T19:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum across</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-sum-across/m-p/356107#M64237</link>
      <description>&lt;P&gt;One more question :&lt;/P&gt;&lt;P&gt;If i have&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8714i6C1BFF4CFB36B329/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="45.png" title="45.png" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And i need to find average of&amp;nbsp;three variables and write to next, but first meaning is missing, so i don't need that;;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data numbers;
input A;
cards;
500
400
300
200
800
200
;
run;

data mean;
set numbers;
first = lag(A);
second=lag2(A);
third=lag3(A);
if _n_ ge 3 then mean= mean(of first,second,third);
final=lag1(mean);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but first of all it find mean of &amp;nbsp; &amp;nbsp;missing value+500+400/3=300&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to change ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2017 20:16:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-sum-across/m-p/356107#M64237</guid>
      <dc:creator>Sizzen</dc:creator>
      <dc:date>2017-05-04T20:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum across</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-sum-across/m-p/356160#M64238</link>
      <description>&lt;P&gt;If you want a value to be counted in the denominator (3) then there must be a value in the numerator. which would have to be 0 if I understand what you are attempting if you want to use the MEAN function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or&lt;/P&gt;
&lt;P&gt;mean = &lt;SPAN class="token function"&gt;sum&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;of &lt;SPAN class="token function"&gt;first&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;second&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;third&lt;SPAN class="token punctuation"&gt;) / 3&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you start getting to complicated requirements to use values that are not in your data then you will have to provide the values using your business logic.&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2017 22:33:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-sum-across/m-p/356160#M64238</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-05-04T22:33:11Z</dc:date>
    </item>
  </channel>
</rss>

