<?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: add new row which will sum all row in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/add-new-row-which-will-sum-all-row/m-p/432805#M107235</link>
    <description>&lt;P&gt;And WHY do you want this in a data set? There exists a potential when you add such rows to a data set that the same or similar code gets executed later and that total gets included in a new total?&lt;/P&gt;
&lt;P&gt;If it is for a report that people read then very likely one of the report procedures such as Proc Tabulate, Report or even Print will do column totals.&lt;/P&gt;
&lt;P&gt;Something like:&lt;/P&gt;
&lt;PRE&gt;proc print data=have sumlabel='Total' noobs;
   var sourcetable count_101917 count_102317 count_103017;
   sum   count_101917 count_102317 count_103017;
run;&lt;/PRE&gt;
&lt;P&gt;Of course you have a likely cause of more issues with the existence of your count variables which apparently have dates as part of the name. You would be better off having a data set that had variables:&amp;nbsp;sourcetable dateofcount countvalue for most purposes. One of which is that when you get data from other months your report syntax does not need to change to create a readable report.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc tabulate data=have;
   class sourcetable dateofcount;
   /* and if you make the dateofcount an actual SAS date value*/
   format dateofcount date9.;
   var count;
   tables sourcetable='' all='Total',
          dateofcount='' * count*sum
   ;
run;&lt;/PRE&gt;
&lt;P&gt;Which report would be useable for &lt;STRONG&gt;many&lt;/STRONG&gt; date periods without having to add a variable for each additional time period.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PLUS you could even use formats to create column totals for calendar months, quarters or years just by changing the format of the date variable.&lt;/P&gt;</description>
    <pubDate>Wed, 31 Jan 2018 15:57:38 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-01-31T15:57:38Z</dc:date>
    <item>
      <title>add new row which will sum all row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-new-row-which-will-sum-all-row/m-p/432602#M107157</link>
      <description>&lt;P&gt;I have a table&amp;nbsp; having 4 columns&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Sourcetable&lt;/TD&gt;&lt;TD&gt;Count_101917&lt;/TD&gt;&lt;TD&gt;Count_102317&lt;/TD&gt;&lt;TD&gt;Count_103017&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;CRS&lt;/TD&gt;&lt;TD&gt;6339&lt;/TD&gt;&lt;TD&gt;6458&lt;/TD&gt;&lt;TD&gt;11914&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;CRS-Insight&lt;/TD&gt;&lt;TD&gt;988&lt;/TD&gt;&lt;TD&gt;1066&lt;/TD&gt;&lt;TD&gt;1065&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;CRS-Insight-Rater&lt;/TD&gt;&lt;TD&gt;4520&lt;/TD&gt;&lt;TD&gt;4512&lt;/TD&gt;&lt;TD&gt;4560&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;CRS-Rater&lt;/TD&gt;&lt;TD&gt;978&lt;/TD&gt;&lt;TD&gt;1007&lt;/TD&gt;&lt;TD&gt;1064&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;InInsightOnly&lt;/TD&gt;&lt;TD&gt;3367&lt;/TD&gt;&lt;TD&gt;3375&lt;/TD&gt;&lt;TD&gt;3515&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;InRaterAndInsight&lt;/TD&gt;&lt;TD&gt;51&lt;/TD&gt;&lt;TD&gt;37&lt;/TD&gt;&lt;TD&gt;35&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;InRaterOnly&lt;/TD&gt;&lt;TD&gt;5958&lt;/TD&gt;&lt;TD&gt;6052&lt;/TD&gt;&lt;TD&gt;6298&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to add new row at the end which will do summation, so I want my output to be:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Sourcetable&lt;/TD&gt;&lt;TD&gt;Count_101917&lt;/TD&gt;&lt;TD&gt;Count_102317&lt;/TD&gt;&lt;TD&gt;Count_103017&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;CRS&lt;/TD&gt;&lt;TD&gt;6339&lt;/TD&gt;&lt;TD&gt;6458&lt;/TD&gt;&lt;TD&gt;11914&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;CRS-Insight&lt;/TD&gt;&lt;TD&gt;988&lt;/TD&gt;&lt;TD&gt;1066&lt;/TD&gt;&lt;TD&gt;1065&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;CRS-Insight-Rater&lt;/TD&gt;&lt;TD&gt;4520&lt;/TD&gt;&lt;TD&gt;4512&lt;/TD&gt;&lt;TD&gt;4560&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;CRS-Rater&lt;/TD&gt;&lt;TD&gt;978&lt;/TD&gt;&lt;TD&gt;1007&lt;/TD&gt;&lt;TD&gt;1064&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;InInsightOnly&lt;/TD&gt;&lt;TD&gt;3367&lt;/TD&gt;&lt;TD&gt;3375&lt;/TD&gt;&lt;TD&gt;3515&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;InRaterAndInsight&lt;/TD&gt;&lt;TD&gt;51&lt;/TD&gt;&lt;TD&gt;37&lt;/TD&gt;&lt;TD&gt;35&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;InRaterOnly&lt;/TD&gt;&lt;TD&gt;5958&lt;/TD&gt;&lt;TD&gt;6052&lt;/TD&gt;&lt;TD&gt;6298&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Total&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;22201&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;22507&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;28451&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 31 Jan 2018 04:28:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-new-row-which-will-sum-all-row/m-p/432602#M107157</guid>
      <dc:creator>subrat1</dc:creator>
      <dc:date>2018-01-31T04:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: add new row which will sum all row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-new-row-which-will-sum-all-row/m-p/432606#M107158</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. array, retain and sum statement&lt;/P&gt;&lt;P&gt;2. transpose and row sum&lt;/P&gt;&lt;P&gt;3. any proc sum and&amp;nbsp; output to dataset and merge back&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;which one do you want?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/90394"&gt;@subrat1&lt;/a&gt;&amp;nbsp;I am disappointed that you don't seem to mark answers as complete in quite a few questions that you asked before. I would appreciate that courtesy&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 04:38:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-new-row-which-will-sum-all-row/m-p/432606#M107158</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-31T04:38:34Z</dc:date>
    </item>
    <item>
      <title>Re: add new row which will sum all row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-new-row-which-will-sum-all-row/m-p/432618#M107163</link>
      <description>&lt;P&gt;one way to do this&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select Sourcetable ,	Count_101917,	Count_102317,	Count_103017
from have
union all
select 'Total' as Sourcetable ,	sum(Count_101917),	sum(Count_102317),	sum(count_103017)
from have
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 Jan 2018 06:28:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-new-row-which-will-sum-all-row/m-p/432618#M107163</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2018-01-31T06:28:48Z</dc:date>
    </item>
    <item>
      <title>Re: add new row which will sum all row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-new-row-which-will-sum-all-row/m-p/432619#M107164</link>
      <description>&lt;P&gt;Correction:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table new_have as
select Sourcetable ,	Count_101917,	Count_102317,	Count_103017
from have
union all
select 'Total' as Sourcetable ,	sum(Count_101917),	sum(Count_102317),	sum(count_103017)
from have
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 Jan 2018 06:50:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-new-row-which-will-sum-all-row/m-p/432619#M107164</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2018-01-31T06:50:44Z</dc:date>
    </item>
    <item>
      <title>Re: add new row which will sum all row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/add-new-row-which-will-sum-all-row/m-p/432805#M107235</link>
      <description>&lt;P&gt;And WHY do you want this in a data set? There exists a potential when you add such rows to a data set that the same or similar code gets executed later and that total gets included in a new total?&lt;/P&gt;
&lt;P&gt;If it is for a report that people read then very likely one of the report procedures such as Proc Tabulate, Report or even Print will do column totals.&lt;/P&gt;
&lt;P&gt;Something like:&lt;/P&gt;
&lt;PRE&gt;proc print data=have sumlabel='Total' noobs;
   var sourcetable count_101917 count_102317 count_103017;
   sum   count_101917 count_102317 count_103017;
run;&lt;/PRE&gt;
&lt;P&gt;Of course you have a likely cause of more issues with the existence of your count variables which apparently have dates as part of the name. You would be better off having a data set that had variables:&amp;nbsp;sourcetable dateofcount countvalue for most purposes. One of which is that when you get data from other months your report syntax does not need to change to create a readable report.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc tabulate data=have;
   class sourcetable dateofcount;
   /* and if you make the dateofcount an actual SAS date value*/
   format dateofcount date9.;
   var count;
   tables sourcetable='' all='Total',
          dateofcount='' * count*sum
   ;
run;&lt;/PRE&gt;
&lt;P&gt;Which report would be useable for &lt;STRONG&gt;many&lt;/STRONG&gt; date periods without having to add a variable for each additional time period.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PLUS you could even use formats to create column totals for calendar months, quarters or years just by changing the format of the date variable.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 15:57:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/add-new-row-which-will-sum-all-row/m-p/432805#M107235</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-01-31T15:57:38Z</dc:date>
    </item>
  </channel>
</rss>

