<?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: Creating a Sum total for each Group? in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Creating-a-Sum-total-for-each-Group/m-p/773998#M25362</link>
    <description>&lt;P&gt;Using data set SASHELP.CLASS, I can produce the requested report&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sashelp.class out=class;
    by sex;
run;
data class;
    set class;
    by sex;
    if first.sex then index=0;
    index+1;
    sample=cats('Sample',index);
    drop index;
run;

/* Now I have a data set similar to yours */
/* PROC REPORT does the rest */
proc report data=class;
    columns sex sample height;
    define sex/group;
    define sample/display;
    define height/sum;
    break after sex/summarize;
    compute after sex;
        sample='Total';
        sex=' ';
    endcompute;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 14 Oct 2021 12:31:11 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-10-14T12:31:11Z</dc:date>
    <item>
      <title>Creating a Sum total for each Group?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Creating-a-Sum-total-for-each-Group/m-p/773996#M25360</link>
      <description>&lt;P&gt;I am trying to recreate a table with the following layout&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mcook_0-1634144792679.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64661i56E9CDA0EBF5642C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mcook_0-1634144792679.png" alt="mcook_0-1634144792679.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The input dataset is simply the 3 columns,&amp;nbsp; Grouping, Var1, and N1&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mcook_1-1634145295070.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64662i4CCB338E3917E089/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mcook_1-1634145295070.png" alt="mcook_1-1634145295070.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do i create the Total for each Group?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 17:18:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Creating-a-Sum-total-for-each-Group/m-p/773996#M25360</guid>
      <dc:creator>mcook</dc:creator>
      <dc:date>2021-10-13T17:18:00Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Sum total for each Group?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Creating-a-Sum-total-for-each-Group/m-p/773997#M25361</link>
      <description>&lt;P&gt;Apologies, i forgot to specify.&amp;nbsp; I am trying to accomplish this in ODS Tagsets.RTF Proc Report.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 17:20:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Creating-a-Sum-total-for-each-Group/m-p/773997#M25361</guid>
      <dc:creator>mcook</dc:creator>
      <dc:date>2021-10-13T17:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Sum total for each Group?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Creating-a-Sum-total-for-each-Group/m-p/773998#M25362</link>
      <description>&lt;P&gt;Using data set SASHELP.CLASS, I can produce the requested report&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sashelp.class out=class;
    by sex;
run;
data class;
    set class;
    by sex;
    if first.sex then index=0;
    index+1;
    sample=cats('Sample',index);
    drop index;
run;

/* Now I have a data set similar to yours */
/* PROC REPORT does the rest */
proc report data=class;
    columns sex sample height;
    define sex/group;
    define sample/display;
    define height/sum;
    break after sex/summarize;
    compute after sex;
        sample='Total';
        sex=' ';
    endcompute;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Oct 2021 12:31:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Creating-a-Sum-total-for-each-Group/m-p/773998#M25362</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-14T12:31:11Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Sum total for each Group?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Creating-a-Sum-total-for-each-Group/m-p/774192#M25367</link>
      <description>&lt;P&gt;How about this one ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods Tagsets.RTF file='c:\temp\temp.rtf' style=journal;
proc sql;
create table have as
select sex,1 as id,Smoking_Status,sum(weight) as weight
 from sashelp.heart
  group by sex,Smoking_Status
union
select sex,2 as id,'Total',sum(weight) as weight
 from sashelp.heart
  group by sex
;
quit;


proc report data=have nowd spanrows missing
style(report)={rules=cols } 
style(header)={fontstyle=roman fontweight=bold background=verylightgrey borderbottomcolor=black borderbottomwidth=2px}  ;
    columns sex id Smoking_Status  weight;
    define sex/group style={just=c vjust=m  bordertopcolor=black bordertopwidth=2px};
 define id/group noprint;
    define Smoking_Status/group;
    define weight/display;
 compute Smoking_Status;
     if Smoking_Status='Total' then 
call define(_row_,'style','style={bordertopcolor=black bordertopwidth=2px borderbottomcolor=black borderbottomwidth=2px}');
 endcomp;
run;
ods Tagsets.RTF close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="20211014200139.png" style="width: 274px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64699i3DDBB2F78E0DA56C/image-size/large?v=v2&amp;amp;px=999" role="button" title="20211014200139.png" alt="20211014200139.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Oct 2021 12:02:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Creating-a-Sum-total-for-each-Group/m-p/774192#M25367</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-10-14T12:02:05Z</dc:date>
    </item>
  </channel>
</rss>

