<?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: ODS RTF Proc Report with multiple dividing groups? in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-RTF-Proc-Report-with-multiple-dividing-groups/m-p/774413#M25382</link>
    <description>&lt;P&gt;Yes, this is doable in SAS quite easily. Look into PROC REPORT.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can match the format probably as exactly as shown.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a reference to get you started:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/resources/papers/proceedings/pdfs/sgf2008/031-2008.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings/pdfs/sgf2008/031-2008.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This paper covers more of the styling options:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.lexjansen.com/sesug/2017/RIV-31.pdf" target="_blank"&gt;https://www.lexjansen.com/sesug/2017/RIV-31.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/319809"&gt;@mcook&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Using ODS RTF (or Tagsets.RTF) I am trying to create this Table from this Dataset.&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="Capture.PNG" style="width: 466px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64741i27203156D5E5D49D/image-dimensions/466x254?v=v2" width="466" height="254" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&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-1634256501852.png" style="width: 467px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64740i8AF222B80DC31FFB/image-dimensions/467x203?v=v2" width="467" height="203" role="button" title="mcook_0-1634256501852.png" alt="mcook_0-1634256501852.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;This Table was not created in SAS, so I don't know if it is possible to match exactly.&amp;nbsp; But any suggestions on how to get close would be extremely helpful.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 15 Oct 2021 02:12:52 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-10-15T02:12:52Z</dc:date>
    <item>
      <title>ODS RTF Proc Report with multiple dividing groups?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-RTF-Proc-Report-with-multiple-dividing-groups/m-p/774392#M25380</link>
      <description>&lt;P&gt;Using ODS RTF (or Tagsets.RTF) I am trying to create this Table from this Dataset.&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="Capture.PNG" style="width: 466px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64741i27203156D5E5D49D/image-dimensions/466x254?v=v2" width="466" height="254" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&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-1634256501852.png" style="width: 467px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64740i8AF222B80DC31FFB/image-dimensions/467x203?v=v2" width="467" height="203" role="button" title="mcook_0-1634256501852.png" alt="mcook_0-1634256501852.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;This Table was not created in SAS, so I don't know if it is possible to match exactly.&amp;nbsp; But any suggestions on how to get close would be extremely helpful.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 00:15:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-RTF-Proc-Report-with-multiple-dividing-groups/m-p/774392#M25380</guid>
      <dc:creator>mcook</dc:creator>
      <dc:date>2021-10-15T00:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: ODS RTF Proc Report with multiple dividing groups?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-RTF-Proc-Report-with-multiple-dividing-groups/m-p/774394#M25381</link>
      <description>&lt;P&gt;the code for the dataset is here&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Temp1;
length Groups SubGroups $ 20;
input Groups $ SubGroups $ nCount Var1 Var2 Var3 Var4 Var5;
datalines;
Group1 SubGroup1A 27 22.67 9.80 -0.70 0.90 70.73
Group1 SubGroup1B 27 23.67 77.27 0.00 0.93 77.70
Group2 SubGroup2A 10 -- -- 0.38 0.93 77.77
Group2 SubGroup2B 10 -- -- -0.89 0.89 9.60
Group2 SubGroup2C 10 79.70 9.77 -0.56 -- --
Group2 SubGroup2D 10 -- -- -0.79 0.99 72.03
Group2 SubGroup2E 14 29.20 70.92 0.00 0.92 70.89
Group3 SubGroup3A 25 23.78 70.59 0.00 0.92 77.06
Group3 SubGroup3B 29 -- -- -0.63 -- --
Total Total 54 45.03 33.00 99.04 43.33 12.01
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Oct 2021 00:33:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-RTF-Proc-Report-with-multiple-dividing-groups/m-p/774394#M25381</guid>
      <dc:creator>mcook</dc:creator>
      <dc:date>2021-10-15T00:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: ODS RTF Proc Report with multiple dividing groups?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-RTF-Proc-Report-with-multiple-dividing-groups/m-p/774413#M25382</link>
      <description>&lt;P&gt;Yes, this is doable in SAS quite easily. Look into PROC REPORT.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can match the format probably as exactly as shown.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a reference to get you started:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/resources/papers/proceedings/pdfs/sgf2008/031-2008.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings/pdfs/sgf2008/031-2008.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This paper covers more of the styling options:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.lexjansen.com/sesug/2017/RIV-31.pdf" target="_blank"&gt;https://www.lexjansen.com/sesug/2017/RIV-31.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/319809"&gt;@mcook&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Using ODS RTF (or Tagsets.RTF) I am trying to create this Table from this Dataset.&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="Capture.PNG" style="width: 466px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64741i27203156D5E5D49D/image-dimensions/466x254?v=v2" width="466" height="254" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&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-1634256501852.png" style="width: 467px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64740i8AF222B80DC31FFB/image-dimensions/467x203?v=v2" width="467" height="203" role="button" title="mcook_0-1634256501852.png" alt="mcook_0-1634256501852.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;This Table was not created in SAS, so I don't know if it is possible to match exactly.&amp;nbsp; But any suggestions on how to get close would be extremely helpful.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 02:12:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-RTF-Proc-Report-with-multiple-dividing-groups/m-p/774413#M25382</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-10-15T02:12:52Z</dc:date>
    </item>
    <item>
      <title>Re: ODS RTF Proc Report with multiple dividing groups?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-RTF-Proc-Report-with-multiple-dividing-groups/m-p/774471#M25385</link>
      <description>&lt;P&gt;It is a piece of cake for sas.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Temp1;
length Groups SubGroups $ 20;
input Groups $ SubGroups $ (nCount Var1 Var2 Var3 Var4 Var5) (?? :best.);
datalines;
Group1 SubGroup1A 27 22.67 9.80 -0.70 0.90 70.73
Group1 SubGroup1B 27 23.67 77.27 0.00 0.93 77.70
Group2 SubGroup2A 10 -- -- 0.38 0.93 77.77
Group2 SubGroup2B 10 -- -- -0.89 0.89 9.60
Group2 SubGroup2C 10 79.70 9.77 -0.56 -- --
Group2 SubGroup2D 10 -- -- -0.79 0.99 72.03
Group2 SubGroup2E 14 29.20 70.92 0.00 0.92 70.89
Group3 SubGroup3A 25 23.78 70.59 0.00 0.92 77.06
Group3 SubGroup3B 29 -- -- -0.63 -- --
Total Total 54 45.03 33.00 99.04 43.33 12.01
;
run;

proc format;
value fmt
.='--';
run;;


data have;
 set temp1;
 if Groups='Total' then Groups='  '||Groups;
run;

ods rtf file='c:\temp\temp.rtf' style=journal bodytitle;
proc report data=have nowd  
style(header)={background=verylightgray fontstyle=roman fontweight=bold just=c borderbottomcolor=black borderbottomwidth=2}
style(report)={rules=cols outputwidth=100% } 
style(lines)={just=l bordertopcolor=black bordertopwidth=2 borderbottomcolor=black borderbottomwidth=2 background=grayee fontweight=bold};
define groups/group noprint;
define SubGroups/group style={just=r } style(header)={just=c} 'Groups';
define nCount/sum style={just=c} format=fmt.;
define var1-var5/sum style={just=c}  format=fmt.;

compute before groups;
if strip(Groups)='Total' then len=0;
 else len=20;
line groups $varying20. len;
endcomp;
run;
ods 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="x.png" style="width: 786px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64758i735C4F8111AA764F/image-size/large?v=v2&amp;amp;px=999" role="button" title="x.png" alt="x.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 11:55:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-RTF-Proc-Report-with-multiple-dividing-groups/m-p/774471#M25385</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-10-15T11:55:20Z</dc:date>
    </item>
    <item>
      <title>Re: ODS RTF Proc Report with multiple dividing groups?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-RTF-Proc-Report-with-multiple-dividing-groups/m-p/774549#M25390</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/319809"&gt;@mcook&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's a really&amp;nbsp;delicious piece of cake.&amp;nbsp; I would like to ask&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;for a little bit more difficult table: If I have more data, the table will take a few pages.&amp;nbsp; What SAS can do to make the Total row on the top of each page, the the group header row also follows the data.&amp;nbsp; I made a few copies of the data and paste, so the table will have two pages.&amp;nbsp; See the code, using your program.&amp;nbsp; The attached file is an example of what I want, and it was created by a SAS macro and data _null_.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data Temp1;
length Groups SubGroups $ 20;
input Groups $ SubGroups $ (nCount Var1 Var2 Var3 Var4 Var5) (?? :best.);
datalines;
Group1 SubGroup1A 27 22.67 9.80 -0.70 0.90 70.73
Group1 SubGroup1B 27 23.67 77.27 0.00 0.93 77.70
Group2 SubGroup2A 10 -- -- 0.38 0.93 77.77
Group2 SubGroup2B 10 -- -- -0.89 0.89 9.60
Group2 SubGroup2C 10 79.70 9.77 -0.56 -- --
Group2 SubGroup2D 10 -- -- -0.79 0.99 72.03
Group2 SubGroup2E 14 29.20 70.92 0.00 0.92 70.89
Group3 SubGroup3A 25 23.78 70.59 0.00 0.92 77.06
Group3 SubGroup3B 29 -- -- -0.63 -- --
Group4 SubGroup1A 27 22.67 9.80 -0.70 0.90 70.73
Group4 SubGroup1B 27 23.67 77.27 0.00 0.93 77.70
Group5 SubGroup2A 10 -- -- 0.38 0.93 77.77
Group5 SubGroup2B 10 -- -- -0.89 0.89 9.60
Group5 SubGroup2C 10 79.70 9.77 -0.56 -- --
Group5 SubGroup2D 10 -- -- -0.79 0.99 72.03
Group5 SubGroup2E 14 29.20 70.92 0.00 0.92 70.89
Group6 SubGroup3A 25 23.78 70.59 0.00 0.92 77.06
Group6 SubGroup3B 29 -- -- -0.63 -- --
Group7 SubGroup1A 27 22.67 9.80 -0.70 0.90 70.73
Group7 SubGroup1B 27 23.67 77.27 0.00 0.93 77.70
Group8 SubGroup2A 10 -- -- 0.38 0.93 77.77
Group8 SubGroup2B 10 -- -- -0.89 0.89 9.60
Group8 SubGroup2C 10 79.70 9.77 -0.56 -- --
Group8 SubGroup2D 10 -- -- -0.79 0.99 72.03
Group8 SubGroup2E 14 29.20 70.92 0.00 0.92 70.89
Group9 SubGroup3A 25 23.78 70.59 0.00 0.92 77.06
Group9 SubGroup3B 29 -- -- -0.63 -- --
Group10 SubGroup1A 27 22.67 9.80 -0.70 0.90 70.73
Group10 SubGroup1B 27 23.67 77.27 0.00 0.93 77.70
Group11 SubGroup2A 10 -- -- 0.38 0.93 77.77
Group11 SubGroup2B 10 -- -- -0.89 0.89 9.60
Group12 SubGroup2C 10 79.70 9.77 -0.56 -- --
Group12 SubGroup2D 10 -- -- -0.79 0.99 72.03
Group12 SubGroup2E 14 29.20 70.92 0.00 0.92 70.89
Group13 SubGroup3A 25 23.78 70.59 0.00 0.92 77.06
Group13 SubGroup3B 29 -- -- -0.63 -- --
Total Total 54 45.03 33.00 99.04 43.33 12.01
;
run;

proc format;
value fmt
.='--';
run;;


data have;
 set temp1;
 if Groups='Total' then Groups='  '||Groups;
run;

ods rtf file='~/sasout/KsSharp.rtf' style=journal bodytitle;
proc report data=have nowd  
style(header)={background=verylightgray fontstyle=roman fontweight=bold just=c borderbottomcolor=black borderbottomwidth=2}
style(report)={rules=cols outputwidth=100% } 
style(lines)={just=l bordertopcolor=black bordertopwidth=2 borderbottomcolor=black borderbottomwidth=2 background=grayee fontweight=bold};
define groups/group noprint;
define SubGroups/group style={just=r } style(header)={just=c} 'Groups';
define nCount/sum style={just=c} format=fmt.;
define var1-var5/sum style={just=c}  format=fmt.;

compute before groups;
if strip(Groups)='Total' then len=0;
 else len=20;
line groups $varying20. len;
endcomp;
run;
ods rtf close;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many Thanks&lt;/P&gt;
&lt;P&gt;Jianmin&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 15:48:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-RTF-Proc-Report-with-multiple-dividing-groups/m-p/774549#M25390</guid>
      <dc:creator>Jianmin</dc:creator>
      <dc:date>2021-10-15T15:48:21Z</dc:date>
    </item>
    <item>
      <title>Re: ODS RTF Proc Report with multiple dividing groups?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-RTF-Proc-Report-with-multiple-dividing-groups/m-p/774666#M25391</link>
      <description>&lt;P&gt;It is a piece of cake for sas.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data Temp1;
length Groups SubGroups $ 20;
input Groups $ SubGroups $ (nCount Var1 Var2 Var3 Var4 Var5) (?? :best.);
datalines;
Group1 SubGroup1A 27 22.67 9.80 -0.70 0.90 70.73
Group1 SubGroup1B 27 23.67 77.27 0.00 0.93 77.70
Group2 SubGroup2A 10 -- -- 0.38 0.93 77.77
Group2 SubGroup2B 10 -- -- -0.89 0.89 9.60
Group2 SubGroup2C 10 79.70 9.77 -0.56 -- --
Group2 SubGroup2D 10 -- -- -0.79 0.99 72.03
Group2 SubGroup2E 14 29.20 70.92 0.00 0.92 70.89
Group3 SubGroup3A 25 23.78 70.59 0.00 0.92 77.06
Group3 SubGroup3B 29 -- -- -0.63 -- --
Group4 SubGroup1A 27 22.67 9.80 -0.70 0.90 70.73
Group4 SubGroup1B 27 23.67 77.27 0.00 0.93 77.70
Group5 SubGroup2A 10 -- -- 0.38 0.93 77.77
Group5 SubGroup2B 10 -- -- -0.89 0.89 9.60
Group5 SubGroup2C 10 79.70 9.77 -0.56 -- --
Group5 SubGroup2D 10 -- -- -0.79 0.99 72.03
Group5 SubGroup2E 14 29.20 70.92 0.00 0.92 70.89
Group6 SubGroup3A 25 23.78 70.59 0.00 0.92 77.06
Group6 SubGroup3B 29 -- -- -0.63 -- --
Group7 SubGroup1A 27 22.67 9.80 -0.70 0.90 70.73
Group7 SubGroup1B 27 23.67 77.27 0.00 0.93 77.70
Group8 SubGroup2A 10 -- -- 0.38 0.93 77.77
Group8 SubGroup2B 10 -- -- -0.89 0.89 9.60
Group8 SubGroup2C 10 79.70 9.77 -0.56 -- --
Group8 SubGroup2D 10 -- -- -0.79 0.99 72.03
Group8 SubGroup2E 14 29.20 70.92 0.00 0.92 70.89
Group9 SubGroup3A 25 23.78 70.59 0.00 0.92 77.06
Group9 SubGroup3B 29 -- -- -0.63 -- --
Group10 SubGroup1A 27 22.67 9.80 -0.70 0.90 70.73
Group10 SubGroup1B 27 23.67 77.27 0.00 0.93 77.70
Group11 SubGroup2A 10 -- -- 0.38 0.93 77.77
Group11 SubGroup2B 10 -- -- -0.89 0.89 9.60
Group12 SubGroup2C 10 79.70 9.77 -0.56 -- --
Group12 SubGroup2D 10 -- -- -0.79 0.99 72.03
Group12 SubGroup2E 14 29.20 70.92 0.00 0.92 70.89
Group13 SubGroup3A 25 23.78 70.59 0.00 0.92 77.06
Group13 SubGroup3B 29 -- -- -0.63 -- --
Total Total 54 45.03 33.00 99.04 43.33 12.01
;
run;

proc format;
value fmt
.='--';
run;;


data have label;
 set temp1;
 if Groups='Total' then output label;
  else output have;
run;
proc transpose data=label out=label1;
var _all_;
run;
proc sql noprint;
select catt(_NAME_,"='",col1,"'") into :label separated by ' '
 from label1;
quit;
proc datasets library=work nolist nodetails;
modify have;
label &amp;amp;label. ;
quit;


title;
ods rtf file='c:\temp\temp.rtf' style=journal bodytitle;
proc report data=have nowd  spanrows
style(header)={background=verylightgray fontstyle=roman fontweight=bold just=c borderbottomcolor=black borderbottomwidth=2}
style(report)={rules=cols outputwidth=100% } 
style(lines)={just=l bordertopcolor=black bordertopwidth=2 borderbottomcolor=black borderbottomwidth=2 background=grayee foreground=black fontweight=bold};
columns ('Groups' Groups) ('SubGroups' SubGroups) ('nCount' nCount)
('Var1' Var1) ('Var2' Var2) ('Var3' Var3) ('Var4' Var4) ('Var5' Var5);

define groups/group noprint;
define SubGroups/group style={just=r } style(header)={just=c} ;
define nCount/sum style={just=c} format=fmt.;
define var1-var5/sum style={just=c}  format=fmt.;

compute before groups;
line groups $100.;
endcomp;
run;
ods rtf close;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1634380220350.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64775i8A67EF8AE6D5CAD2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1634380220350.png" alt="Ksharp_0-1634380220350.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_2-1634380254623.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64777i96EB0A2264925327/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_2-1634380254623.png" alt="Ksharp_2-1634380254623.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Oct 2021 10:31:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-RTF-Proc-Report-with-multiple-dividing-groups/m-p/774666#M25391</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-10-16T10:31:00Z</dc:date>
    </item>
    <item>
      <title>Re: ODS RTF Proc Report with multiple dividing groups?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-RTF-Proc-Report-with-multiple-dividing-groups/m-p/774683#M25392</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's very clever to use the label statement to modify the dataset. I'm still dizzy to get around this concept, but I'll continue to study your code.&amp;nbsp; It's still a good piece of cake, but one thing you didn't do is that to get the group follows the data.&amp;nbsp; &amp;nbsp;For example, the Group6 now is on two different pages, can we have Group6 also on the top of page 2?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Jianmin_2-1634399448775.png" style="width: 669px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64780i4761CC4D52CDB37B/image-dimensions/669x354?v=v2" width="669" height="354" role="button" title="Jianmin_2-1634399448775.png" alt="Jianmin_2-1634399448775.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Many Thanks&lt;/P&gt;
&lt;P&gt;Jianmin Long&lt;/P&gt;</description>
      <pubDate>Sat, 16 Oct 2021 15:53:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-RTF-Proc-Report-with-multiple-dividing-groups/m-p/774683#M25392</guid>
      <dc:creator>Jianmin</dc:creator>
      <dc:date>2021-10-16T15:53:03Z</dc:date>
    </item>
    <item>
      <title>Re: ODS RTF Proc Report with multiple dividing groups?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-RTF-Proc-Report-with-multiple-dividing-groups/m-p/774714#M25393</link>
      <description>&lt;P&gt;It is a piece of cake for sas.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Temp1;
length Groups SubGroups $ 20;
input Groups $ SubGroups $ (nCount Var1 Var2 Var3 Var4 Var5) (?? :best.);
datalines;
Group1 SubGroup1A 27 22.67 9.80 -0.70 0.90 70.73
Group1 SubGroup1B 27 23.67 77.27 0.00 0.93 77.70
Group2 SubGroup2A 10 -- -- 0.38 0.93 77.77
Group2 SubGroup2B 10 -- -- -0.89 0.89 9.60
Group2 SubGroup2C 10 79.70 9.77 -0.56 -- --
Group2 SubGroup2D 10 -- -- -0.79 0.99 72.03
Group2 SubGroup2E 14 29.20 70.92 0.00 0.92 70.89
Group3 SubGroup3A 25 23.78 70.59 0.00 0.92 77.06
Group3 SubGroup3B 29 -- -- -0.63 -- --
Group4 SubGroup1A 27 22.67 9.80 -0.70 0.90 70.73
Group4 SubGroup1B 27 23.67 77.27 0.00 0.93 77.70
Group5 SubGroup2A 10 -- -- 0.38 0.93 77.77
Group5 SubGroup2B 10 -- -- -0.89 0.89 9.60
Group5 SubGroup2C 10 79.70 9.77 -0.56 -- --
Group5 SubGroup2D 10 -- -- -0.79 0.99 72.03
Group5 SubGroup2E 14 29.20 70.92 0.00 0.92 70.89
Group6 SubGroup3A 25 23.78 70.59 0.00 0.92 77.06
Group6 SubGroup3B 29 -- -- -0.63 -- --
Group7 SubGroup1A 27 22.67 9.80 -0.70 0.90 70.73
Group7 SubGroup1B 27 23.67 77.27 0.00 0.93 77.70
Group8 SubGroup2A 10 -- -- 0.38 0.93 77.77
Group8 SubGroup2B 10 -- -- -0.89 0.89 9.60
Group8 SubGroup2C 10 79.70 9.77 -0.56 -- --
Group8 SubGroup2D 10 -- -- -0.79 0.99 72.03
Group8 SubGroup2E 14 29.20 70.92 0.00 0.92 70.89
Group9 SubGroup3A 25 23.78 70.59 0.00 0.92 77.06
Group9 SubGroup3B 29 -- -- -0.63 -- --
Group10 SubGroup1A 27 22.67 9.80 -0.70 0.90 70.73
Group10 SubGroup1B 27 23.67 77.27 0.00 0.93 77.70
Group11 SubGroup2A 10 -- -- 0.38 0.93 77.77
Group11 SubGroup2B 10 -- -- -0.89 0.89 9.60
Group12 SubGroup2C 10 79.70 9.77 -0.56 -- --
Group12 SubGroup2D 10 -- -- -0.79 0.99 72.03
Group12 SubGroup2E 14 29.20 70.92 0.00 0.92 70.89
Group13 SubGroup3A 25 23.78 70.59 0.00 0.92 77.06
Group13 SubGroup3B 29 -- -- -0.63 -- --
Total Total 54 45.03 33.00 99.04 43.33 12.01
;
run;

proc format;
value fmt
.='--';
run;;


data have label;
 set temp1;
 if Groups='Total' then output label;
  else output have;
run;
proc transpose data=label out=label1;
var _all_;
run;
proc sql noprint;
select catt(_NAME_,"='",col1,"'") into :label separated by ' ' from label1;
select catx(" ","('",_NAME_,"'",_NAME_,")") into :header separated by ' ' from label1;

create table have2 as
select *,count(*) as n from have group by groups;
quit;
data have3;
 set have2;
 by groups;
 if first.groups then do;
   rows+(n+1);
   if rows&amp;gt;34 then do; /*assuming a page only could have 34 rows*/
     break+1;rows=n+1;
   end;
 end;
run;
proc datasets library=work nolist nodetails;
modify have3;
label &amp;amp;label. ;
quit;








title ;
ods rtf file='c:\temp\temp.rtf' style=journal bodytitle;
proc report data=have3 nowd  spanrows
style(header)={background=verylightgray fontstyle=roman fontweight=bold just=c borderbottomcolor=black borderbottomwidth=2}
style(report)={rules=cols outputwidth=100% } 
style(lines)={just=l bordertopcolor=black bordertopwidth=2 borderbottomcolor=black borderbottomwidth=2 background=grayee foreground=black fontweight=bold};
columns break &amp;amp;header. ;

define break/group noprint;
define groups/group noprint;
define SubGroups/group style={just=r } style(header)={just=c} ;
define nCount/sum style={just=c} format=fmt.;
define var1-var5/sum style={just=c}  format=fmt.;
break after break/page;
compute before groups;
line groups $100.;
endcomp;
run;
ods 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="Ksharp_0-1634467808031.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64792i7D1F25C3B13FC3C1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1634467808031.png" alt="Ksharp_0-1634467808031.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_2-1634467852422.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64794iF20476BE7AC6642F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_2-1634467852422.png" alt="Ksharp_2-1634467852422.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Oct 2021 10:51:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-RTF-Proc-Report-with-multiple-dividing-groups/m-p/774714#M25393</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-10-17T10:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: ODS RTF Proc Report with multiple dividing groups?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-RTF-Proc-Report-with-multiple-dividing-groups/m-p/774740#M25394</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/63490"&gt;@Jianmin&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;KSharp, thank you,&amp;nbsp; Using your code i was able to eventually get my output to look correct.&amp;nbsp; Though what is the purpose of the following data step?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 set temp1;
 if Groups='Total' then Groups='  '||Groups;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;why the empty space before 'Total'?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also,&amp;nbsp; why no column statement?&lt;/P&gt;
&lt;P&gt;if i try to put in a column statement to change the order of the variables,&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;for example&lt;/P&gt;
&lt;P&gt;Column Groups nCount Var3 Var2 Var5 Var4 Var1;&lt;/P&gt;
&lt;P&gt;It outputs a table with the correct ordering , but it drops the Groups column.&amp;nbsp; so i had to order the variables in a proc sql step prior to proc report.&amp;nbsp;&amp;nbsp;&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="Capture.PNG" style="width: 269px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64796i82340905422EAC46/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Oct 2021 17:08:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-RTF-Proc-Report-with-multiple-dividing-groups/m-p/774740#M25394</guid>
      <dc:creator>mcook</dc:creator>
      <dc:date>2021-10-17T17:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: ODS RTF Proc Report with multiple dividing groups?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-RTF-Proc-Report-with-multiple-dividing-groups/m-p/774742#M25395</link>
      <description>&lt;P&gt;Very impressive&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;, it looks like you can do anything in SAS, but I still have question for your later.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;, I have seen&amp;nbsp;Arthur L. Carpenter's writings and all he talked about is to do a table with n rows and m columns.&amp;nbsp; &amp;nbsp;The table&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/319809"&gt;@mcook&lt;/a&gt;&amp;nbsp;asked was a type of table I learned in the early time of my career, and Microsoft had a solution for that in 1990's.&amp;nbsp; The idea of a table is that:&amp;nbsp; a header row followed with a few rows of m columns.&amp;nbsp; Nowadays from the beginning of SAS tables, we don't really see this type of distinction in SAS tables.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;'s solution was really clever, and I haven't seen it in other writings.&amp;nbsp; In&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;'s previous program, he did it right to make first two rows as header rows, you can see this in Word for table property for row: Repeated as header row at the top of each page.&amp;nbsp; In&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;'s most recent program, he didn't make Group as a header row, instead he used a page break.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;In Word, it's really easy to make as many header rows as you like, but I don't know how SAS handles this one.&lt;/P&gt;
&lt;P&gt;The Word doesn't use page break, and there are a lot of wrongs about using page break in SAS.&amp;nbsp;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;'s program suffers a minor defect, you still can break the code with a minor change in the code:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Temp1;
length Groups SubGroups $ 200;
input Groups $ SubGroups $  (nCount Var1 Var2 Var3 Var4 Var5) (?? :best.);
datalines;
Group1 SubGroup1A-SubGroup1A-SubGroup1A-SubGroup1A-SubGroup1A 27 22.67 9.80 -0.70 0.90 70.73
Group1 SubGroup1B-SubGroup1B-SubGroup1B-SubGroup1B-SubGroup1B 27 23.67 77.27 0.00 0.93 77.70
....

define SubGroups/group style={just=r width=0.5in} style(header)={just=c} ;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And other SPANROWS output heavily uses vertical space control methods, the resulting output suffers a lot of defects, and sometimes it is not even a Word document.&amp;nbsp; For example you can't do any editing, for example make a font larger, and hidden text in a row...&lt;/P&gt;
&lt;P&gt;Many thanks for&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;'s effort, and let me know it you know how to make Group as a header row.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jianmin Long&lt;/P&gt;</description>
      <pubDate>Sun, 17 Oct 2021 17:45:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-RTF-Proc-Report-with-multiple-dividing-groups/m-p/774742#M25395</guid>
      <dc:creator>Jianmin</dc:creator>
      <dc:date>2021-10-17T17:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: ODS RTF Proc Report with multiple dividing groups?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-RTF-Proc-Report-with-multiple-dividing-groups/m-p/774864#M25397</link>
      <description>"why the empty space before 'Total'?"&lt;BR /&gt;I want make "Total" row in the first place . sas would order it by character . since blank is before any of A-Z in ASIIC code, so "Total" would be in the first row.&lt;BR /&gt;&lt;BR /&gt;"Also,  why no column statement?"&lt;BR /&gt;Yes. you could define COLUMN statement to order variables by &lt;BR /&gt;Column Groups SubGroup nCount Var3 Var2 Var5 Var4 Var1;&lt;BR /&gt;I didn't write it due to save the code.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;"but it drops the Groups column."&lt;BR /&gt;Yes. Because I used NOPRINT option.&lt;BR /&gt;define groups/group noprint;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 18 Oct 2021 11:56:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-RTF-Proc-Report-with-multiple-dividing-groups/m-p/774864#M25397</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-10-18T11:56:53Z</dc:date>
    </item>
  </channel>
</rss>

