<?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 Add new row with sum in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Add-new-row-with-sum/m-p/35719#M7065</link>
    <description>Is there a way in SAS i can create row after each region for regional total ? &lt;BR /&gt;
&lt;BR /&gt;
For example:  I have table with following columns:&lt;BR /&gt;
&lt;BR /&gt;
Region      Rep          Sales&lt;BR /&gt;
A               1             $100&lt;BR /&gt;
A               2             $500&lt;BR /&gt;
B               3             $200&lt;BR /&gt;
B               4             $1000&lt;BR /&gt;
&lt;BR /&gt;
I would like the results to be:&lt;BR /&gt;
&lt;BR /&gt;
Region      Rep          Sales&lt;BR /&gt;
A               1             $100&lt;BR /&gt;
A               2             $500&lt;BR /&gt;
Total                         $600&lt;BR /&gt;
B               3             $200&lt;BR /&gt;
B               4             $1000&lt;BR /&gt;
Total                         $1200&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
    <pubDate>Tue, 22 Mar 2011 20:16:06 GMT</pubDate>
    <dc:creator>newbi</dc:creator>
    <dc:date>2011-03-22T20:16:06Z</dc:date>
    <item>
      <title>Add new row with sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-new-row-with-sum/m-p/35719#M7065</link>
      <description>Is there a way in SAS i can create row after each region for regional total ? &lt;BR /&gt;
&lt;BR /&gt;
For example:  I have table with following columns:&lt;BR /&gt;
&lt;BR /&gt;
Region      Rep          Sales&lt;BR /&gt;
A               1             $100&lt;BR /&gt;
A               2             $500&lt;BR /&gt;
B               3             $200&lt;BR /&gt;
B               4             $1000&lt;BR /&gt;
&lt;BR /&gt;
I would like the results to be:&lt;BR /&gt;
&lt;BR /&gt;
Region      Rep          Sales&lt;BR /&gt;
A               1             $100&lt;BR /&gt;
A               2             $500&lt;BR /&gt;
Total                         $600&lt;BR /&gt;
B               3             $200&lt;BR /&gt;
B               4             $1000&lt;BR /&gt;
Total                         $1200&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
      <pubDate>Tue, 22 Mar 2011 20:16:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-new-row-with-sum/m-p/35719#M7065</guid>
      <dc:creator>newbi</dc:creator>
      <dc:date>2011-03-22T20:16:06Z</dc:date>
    </item>
    <item>
      <title>Re: Add new row with sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-new-row-with-sum/m-p/35720#M7066</link>
      <description>I figure it out.  Thanks</description>
      <pubDate>Tue, 22 Mar 2011 21:11:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-new-row-with-sum/m-p/35720#M7066</guid>
      <dc:creator>newbi</dc:creator>
      <dc:date>2011-03-22T21:11:23Z</dc:date>
    </item>
    <item>
      <title>Re: Add new row with sum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-new-row-with-sum/m-p/35721#M7067</link>
      <description>Hi:&lt;BR /&gt;
  You can use the SUM statement in PROC PRINT or use PROC REPORT with a BREAK statement. I suppose you could even do this in an SQL query, but I'd stick with PRINT or REPORT first. Consider this example that uses SASHELP.SHOES. Report 1 and Report  2 are "detail" reports because they show every observation for Canada and Pacific regions, with subtotals between each region. On the other hand, Report 3 is a "summary" report because it collapses the Canada observations in groups by region and product and then has a subtotal for the region groups.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
** only get 2 regions;&lt;BR /&gt;
proc sort data=sashelp.shoes out=shoes;&lt;BR /&gt;
  by region product;&lt;BR /&gt;
  where region in ('Canada', 'Pacific');&lt;BR /&gt;
run; &lt;BR /&gt;
            &lt;BR /&gt;
ods listing; &lt;BR /&gt;
ods html file='c:\temp\region_total.html' style=sasweb;&lt;BR /&gt;
               &lt;BR /&gt;
proc print data=shoes;&lt;BR /&gt;
  var region product sales;&lt;BR /&gt;
  sum sales;&lt;BR /&gt;
  sumby region;&lt;BR /&gt;
  by region;&lt;BR /&gt;
  title '1) Proc Print Detail Report with Subtotals';&lt;BR /&gt;
run;&lt;BR /&gt;
                                         &lt;BR /&gt;
proc report data=shoes nowd&lt;BR /&gt;
  style(summary)=Header;&lt;BR /&gt;
  column region product sales;&lt;BR /&gt;
  define region / order;&lt;BR /&gt;
  define product/order;&lt;BR /&gt;
  define sales / sum;&lt;BR /&gt;
  break after region / summarize page;&lt;BR /&gt;
  compute after region;&lt;BR /&gt;
    region = 'Total';&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
  title '2) Proc Report Detail Report with Subtotals';&lt;BR /&gt;
run;&lt;BR /&gt;
                               &lt;BR /&gt;
proc report data=shoes nowd&lt;BR /&gt;
  style(summary)=Header;&lt;BR /&gt;
  column region product sales;&lt;BR /&gt;
  define region / group;&lt;BR /&gt;
  define product/group;&lt;BR /&gt;
  define sales / sum;&lt;BR /&gt;
  break after region / summarize;&lt;BR /&gt;
  compute after region;&lt;BR /&gt;
    region = 'Total';&lt;BR /&gt;
  endcomp;&lt;BR /&gt;
  title '3) Proc Report Summary Report with Subtotals';&lt;BR /&gt;
run;&lt;BR /&gt;
                         &lt;BR /&gt;
ods _all_ close;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Tue, 22 Mar 2011 22:32:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-new-row-with-sum/m-p/35721#M7067</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2011-03-22T22:32:45Z</dc:date>
    </item>
  </channel>
</rss>

