<?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: what is the best way to create a new variable with sum in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/what-is-the-best-way-to-create-a-new-variable-with-sum/m-p/296115#M61965</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc sql;
create table sum_row as
select
'all' as trial,
sum(treat1) as treat1,
sum(treat2) as treat2
from have;
quit;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="codeFocus"&gt;proc append base=have data=sum_row;&lt;BR /&gt;&lt;/SPAN&gt;run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 02 Sep 2016 13:53:18 GMT</pubDate>
    <dc:creator>set_all__</dc:creator>
    <dc:date>2016-09-02T13:53:18Z</dc:date>
    <item>
      <title>what is the best way to create a new variable with sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/what-is-the-best-way-to-create-a-new-variable-with-sum/m-p/296077#M61949</link>
      <description>&lt;P&gt;I have a dataset like&lt;/P&gt;
&lt;P&gt;Trial &amp;nbsp; &amp;nbsp; treat1 &amp;nbsp; treat2&lt;/P&gt;
&lt;P&gt;123 &amp;nbsp; &amp;nbsp; &amp;nbsp; 23.2 &amp;nbsp; &amp;nbsp; &amp;nbsp;34.2&lt;/P&gt;
&lt;P&gt;234 &amp;nbsp; &amp;nbsp; &amp;nbsp; 78 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;87&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now i want a last column naming all with sum of the rows&lt;/P&gt;
&lt;P&gt;Trial &amp;nbsp; &amp;nbsp; treat1 &amp;nbsp; treat2&lt;/P&gt;
&lt;P&gt;123 &amp;nbsp; &amp;nbsp; &amp;nbsp; 23.2 &amp;nbsp; &amp;nbsp; &amp;nbsp;34.2&lt;/P&gt;
&lt;P&gt;234 &amp;nbsp; &amp;nbsp; &amp;nbsp; 78 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;87&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;all &amp;nbsp;&lt;/STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;STRONG&gt;101,2 &amp;nbsp; &amp;nbsp;121,2&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Can any one help me in this&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Sep 2016 08:40:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/what-is-the-best-way-to-create-a-new-variable-with-sum/m-p/296077#M61949</guid>
      <dc:creator>vraj1</dc:creator>
      <dc:date>2016-09-02T08:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: what is the best way to create a new variable with sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/what-is-the-best-way-to-create-a-new-variable-with-sum/m-p/296080#M61950</link>
      <description>&lt;P&gt;PROC PRINT.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Sep 2016 09:00:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/what-is-the-best-way-to-create-a-new-variable-with-sum/m-p/296080#M61950</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-09-02T09:00:56Z</dc:date>
    </item>
    <item>
      <title>Re: what is the best way to create a new variable with sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/what-is-the-best-way-to-create-a-new-variable-with-sum/m-p/296115#M61965</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc sql;
create table sum_row as
select
'all' as trial,
sum(treat1) as treat1,
sum(treat2) as treat2
from have;
quit;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="codeFocus"&gt;proc append base=have data=sum_row;&lt;BR /&gt;&lt;/SPAN&gt;run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Sep 2016 13:53:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/what-is-the-best-way-to-create-a-new-variable-with-sum/m-p/296115#M61965</guid>
      <dc:creator>set_all__</dc:creator>
      <dc:date>2016-09-02T13:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: what is the best way to create a new variable with sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/what-is-the-best-way-to-create-a-new-variable-with-sum/m-p/296140#M61973</link>
      <description>&lt;P&gt;I am always very leery of any inserted summary rows inside a data set. What happens if you run the same summary program later on the same data? Or you run a report procedure like Proc Report that generates summary totals. You have now included the summary into a new summary.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At a very minimum I would add an indicator variable to show that the row is indeed some sort of summary and the other rows aren't&amp;nbsp;with appropriate label for the indicator.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Sep 2016 15:27:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/what-is-the-best-way-to-create-a-new-variable-with-sum/m-p/296140#M61973</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-09-02T15:27:07Z</dc:date>
    </item>
  </channel>
</rss>

