<?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: Split header on top of Spanning Header in proc report in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Split-header-on-top-of-Spanning-Header-in-proc-report/m-p/924916#M364046</link>
    <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; What you currently show is what PROC REPORT will give you. I do not think there's a way to get PROC REPORT to do what you want to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I was pleasantly surprised when testing the Report Writing Interface that my program generated the correct results in both ODS RTF and ODS TAGSETS.RTF (yay!), as shown below:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_0-1713472362762.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/95670i814DE331176BF450/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1713472362762.png" alt="Cynthia_sas_0-1713472362762.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I just used SASHELP.IRIS, and presummarized it to get the averages. There are 4 columns in the report plus the Species column, to mimic your columns and then using some headers that are similar to what you want, just as a proof of concept. Here's the code I used:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 
%let mypath=c:\temp;
** presummarize IRIS data to get only averages;
proc means data=sashelp.iris mean maxdec=2;
  class species;
  var sepallength sepalwidth petallength petalwidth;
  output out=work.allavg mean=; 
run;

ods html path="&amp;amp;mypath." file="complex_column_span.html";
ods pdf file="&amp;amp;mypath.\complex_column_span.pdf" ;
ods rtf file="&amp;amp;mypath.\odsr_column_span.rtf";
ods tagsets.rtf file="&amp;amp;mypath.\odstr_column_span.rtf";
title "Complex Column Spanning";
data _null_; 
  set allavg(keep=_type_ species sepallength sepalwidth petallength petalwidth)
      end=last; 
  by species;

  if _N_ = 1 then do; 
      dcl odsout obj(); 
      obj.table_start(); 
      obj.head_start(); 
	  ** Header row 1;
	  obj.row_start(type:"Header");
	  obj.format_cell(text: "Species", row_span:3,style_attr:"color=black backgroundcolor=white vjust=b fontweight=bold"); 
      obj.format_cell(text: "N=111", column_span:2, style_attr:"color=black backgroundcolor=white"); 
      obj.format_cell(text: "N=222", column_span:2, style_attr:"color=black backgroundcolor=white"); 
      obj.row_end(); 
	  ** Header row 2;
	  obj.row_start(type:"Header");
      obj.format_cell(text: "Averages by Species", column_span:4, style_attr:"color=black backgroundcolor=white"); 
      obj.row_end(); 
	  ** Header row 3;
      obj.row_start(type: "Header"); 
      obj.format_cell(text: "SepalLength", style_attr:"color=black backgroundcolor=white fontweight=bold"); 
      obj.format_cell(text: "SepalWidth", style_attr:"color=black backgroundcolor=white fontweight=bold"); 
      obj.format_cell(text: "PetalLength", style_attr:"color=black backgroundcolor=white fontweight=bold"); 
      obj.format_cell(text: "PetalWidth", style_attr:"color=black backgroundcolor=white fontweight=bold"); 
      obj.row_end(); 
      obj.head_end(); 
    end;
  ** row for every obs;
	if _type_ = 1 then do;
      obj.row_start(); 
      obj.format_cell(data: species, row_span:1); 
      obj.format_cell(data: sepallength, row_span:1); 
      obj.format_cell(data: sepalwidth, row_span:1); 
      obj.format_cell(data: petallength, row_span:1); 
      obj.format_cell(data: petalwidth, row_span:1); 
	  obj.row_end();
  end;
  if last then do; 
      obj.table_end(); 
  end; 
run; 
ods html close; 
ods pdf close;
ods rtf close;
ods tagsets.rtf close;

title; footnote;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; I used the _TYPE_=1 rows from the PROC MEANS OUTPUT data set because I did not need the _TYPE_=0 row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Depending on the structure of your data and what you need to do, the Report Writing Interface may be an option.&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 18 Apr 2024 20:36:56 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2024-04-18T20:36:56Z</dc:date>
    <item>
      <title>Split header on top of Spanning Header in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-header-on-top-of-Spanning-Header-in-proc-report/m-p/924879#M364030</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to create a split header on top of a spanning header, but having trouble figuring out how to organize the code.&lt;/P&gt;
&lt;P&gt;Here is what I have:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=all&amp;amp;n  out=vall&amp;amp;n (where=(_break_='' and paramn ^=.))
  headline headskip nowindows missing split = "@"
  style=[protectspecialchars=off] style(report)=[bordertopwidth=1.5];           
	columns sp parcat2n paramn param  
  						
							("(*ESC*)S={borderbottomcolor=black borderbottomwidth=2} Treatment A@(N=&amp;amp;N0.)"
							_0LOW _0HIGH)
							("(*ESC*)S={borderbottomcolor=black borderbottomwidth=2} Treatment B@(N=&amp;amp;N1.)" 
							_1LOW _1HIGH)&lt;BR /&gt;	                        ("(*ESC*)S={borderbottomcolor=black borderbottomwidth=2}  Overall Post-Baseline" 
							_0LOW _0HIGH _1LOW _1HIGH);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV&gt;Not working...but need to look like this:&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jenim514_1-1713459967637.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/95661i0D1EE24D39C3AF1B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jenim514_1-1713459967637.png" alt="jenim514_1-1713459967637.png" /&gt;&lt;/span&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;
&lt;DIV&gt;Any help is appreciated!!&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Thu, 18 Apr 2024 17:06:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-header-on-top-of-Spanning-Header-in-proc-report/m-p/924879#M364030</guid>
      <dc:creator>jenim514</dc:creator>
      <dc:date>2024-04-18T17:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: Split header on top of Spanning Header in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-header-on-top-of-Spanning-Header-in-proc-report/m-p/924892#M364039</link>
      <description>Hi:&lt;BR /&gt;  Without any data or the full code, nobody can play with your example because they either have to guess at the structure of your data or they have to guess what the rest of your program is. You could be trying to get either HTML, RTF or PDF output, so knowing your ODS statements would be useful too. In just a quick look, it's going to be hard to split the column headers the way you show using PROC REPORT. Spanning headers such as you show are more like the type of thing you can do with the Report Writing Interface (RWI) and the DATA step. However, that brings us back to what destination you want because the RWI Interface is not supported in all destinations. &lt;BR /&gt;Cynthia</description>
      <pubDate>Thu, 18 Apr 2024 18:06:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-header-on-top-of-Spanning-Header-in-proc-report/m-p/924892#M364039</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2024-04-18T18:06:07Z</dc:date>
    </item>
    <item>
      <title>Re: Split header on top of Spanning Header in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-header-on-top-of-Spanning-Header-in-proc-report/m-p/924894#M364041</link>
      <description>&lt;P&gt;Are you actually creating multiple columns with the same values?&lt;/P&gt;
&lt;P&gt;Removing the header text that columns statement reduces to&lt;/P&gt;
&lt;PRE&gt;columns sp parcat2n paramn param _0LOW _0HIGH _1LOW _1HIGH _0LOW _0HIGH _1LOW _1HIGH;
&lt;/PRE&gt;
&lt;P&gt;Which has 4 variables repeated and seems like an odd thing to do.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2024 18:50:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-header-on-top-of-Spanning-Header-in-proc-report/m-p/924894#M364041</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-04-18T18:50:25Z</dc:date>
    </item>
    <item>
      <title>Re: Split header on top of Spanning Header in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-header-on-top-of-Spanning-Header-in-proc-report/m-p/924907#M364043</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods listing close;
ods tagsets.rtf file="&amp;amp;outpath" options(vspace='NO') &amp;amp;repopt;

title3 "&amp;amp;ttlnum";
title4 "&amp;amp;ttldesc";
title5 "&amp;amp;ttlpop";
title6 " ";
proc report data=all&amp;amp;n  out=vall&amp;amp;n (where=(_break_='' and paramn ^=.))
  headline headskip nowindows missing split = "@"
  style=[protectspecialchars=off] style(report)=[bordertopwidth=1.5];           
	columns sp parcat2n paramn param  
	 						("(*ESC*)S={borderbottomcolor=black borderbottomwidth=2}  Overall Post-Baseline" 
  							("(*ESC*)S={borderbottomcolor=black borderbottomwidth=2} Treatment A@(N=&amp;amp;N0.)"
							_0LOW _0HIGH)
							("(*ESC*)S={borderbottomcolor=black borderbottomwidth=2} Treatment B@(N=&amp;amp;N1.)" 
							_1LOW _1HIGH));
	                       
						
	define sp	/order	order=internal noprint;
	define parcat2n	/order	order=internal noprint;
	define paramn	/order	order=internal noprint;
	define param    / display   style=[cellwidth=2.85 in just=l asis=on] "Parameter (units)";
	define _0LOW      / display style=[cellwidth=1.5 in just=c asis=on] "Low ~{super a}@n/nn (%)";
	define _0HIGH     / display style=[cellwidth=1.5 in just=c asis=on] "High ~{super b}@n/nn (%)";
	define _1LOW      / display style=[cellwidth=1.5 in just=c asis=on] "Low ~{super a}@n/nn (%)";
	define _1HIGH      / display style=[cellwidth=1.5 in just=c asis=on] "High ~{super b}@n/nn (%)";


	break after parcat2n / page;
	compute before sp;
      line put ' ';
    endcomp;

run;




&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Sorry not duplicating the columns ( I was playing around with the code earlier and realized I didn't revert back).&amp;nbsp; This current code spans 'overall post-baseline' at top, but I actually need it below the split header (Treatment A and Treatment B).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Currently:&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jenim514_0-1713468695648.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/95668iB945E9D5BB66DEC6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jenim514_0-1713468695648.png" alt="jenim514_0-1713468695648.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Need:&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="jenim514_1-1713468737039.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/95669i7A3B02FC011FA2DD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jenim514_1-1713468737039.png" alt="jenim514_1-1713468737039.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2024 19:32:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-header-on-top-of-Spanning-Header-in-proc-report/m-p/924907#M364043</guid>
      <dc:creator>jenim514</dc:creator>
      <dc:date>2024-04-18T19:32:38Z</dc:date>
    </item>
    <item>
      <title>Re: Split header on top of Spanning Header in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-header-on-top-of-Spanning-Header-in-proc-report/m-p/924914#M364045</link>
      <description>&lt;P&gt;Not a direct solution of inserting a single spanning UNDER two (or more) other headings but for some appearances may give a similar enough appearance:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc report data=sashelp.class headline headskip;
columns name ('header first columns' 
              (" "
              sex age))
              (' next block'
              ("other secondline header"
              height weight))
 ;
 run;&lt;/PRE&gt;
&lt;P&gt;Not trying to deal style appearance options as more of demonstration of concept.&lt;/P&gt;
&lt;P&gt;With horizontal justification options in the first line, second and actual variable headers then the "other secondline header" , while not exactly centered (assumption of desire) may be close enough to fool the eye.&lt;/P&gt;
&lt;P&gt;Specifying exact column widths for the variable columns would likely help as well.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2024 20:10:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-header-on-top-of-Spanning-Header-in-proc-report/m-p/924914#M364045</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-04-18T20:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: Split header on top of Spanning Header in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-header-on-top-of-Spanning-Header-in-proc-report/m-p/924916#M364046</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; What you currently show is what PROC REPORT will give you. I do not think there's a way to get PROC REPORT to do what you want to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I was pleasantly surprised when testing the Report Writing Interface that my program generated the correct results in both ODS RTF and ODS TAGSETS.RTF (yay!), as shown below:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_0-1713472362762.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/95670i814DE331176BF450/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1713472362762.png" alt="Cynthia_sas_0-1713472362762.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I just used SASHELP.IRIS, and presummarized it to get the averages. There are 4 columns in the report plus the Species column, to mimic your columns and then using some headers that are similar to what you want, just as a proof of concept. Here's the code I used:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 
%let mypath=c:\temp;
** presummarize IRIS data to get only averages;
proc means data=sashelp.iris mean maxdec=2;
  class species;
  var sepallength sepalwidth petallength petalwidth;
  output out=work.allavg mean=; 
run;

ods html path="&amp;amp;mypath." file="complex_column_span.html";
ods pdf file="&amp;amp;mypath.\complex_column_span.pdf" ;
ods rtf file="&amp;amp;mypath.\odsr_column_span.rtf";
ods tagsets.rtf file="&amp;amp;mypath.\odstr_column_span.rtf";
title "Complex Column Spanning";
data _null_; 
  set allavg(keep=_type_ species sepallength sepalwidth petallength petalwidth)
      end=last; 
  by species;

  if _N_ = 1 then do; 
      dcl odsout obj(); 
      obj.table_start(); 
      obj.head_start(); 
	  ** Header row 1;
	  obj.row_start(type:"Header");
	  obj.format_cell(text: "Species", row_span:3,style_attr:"color=black backgroundcolor=white vjust=b fontweight=bold"); 
      obj.format_cell(text: "N=111", column_span:2, style_attr:"color=black backgroundcolor=white"); 
      obj.format_cell(text: "N=222", column_span:2, style_attr:"color=black backgroundcolor=white"); 
      obj.row_end(); 
	  ** Header row 2;
	  obj.row_start(type:"Header");
      obj.format_cell(text: "Averages by Species", column_span:4, style_attr:"color=black backgroundcolor=white"); 
      obj.row_end(); 
	  ** Header row 3;
      obj.row_start(type: "Header"); 
      obj.format_cell(text: "SepalLength", style_attr:"color=black backgroundcolor=white fontweight=bold"); 
      obj.format_cell(text: "SepalWidth", style_attr:"color=black backgroundcolor=white fontweight=bold"); 
      obj.format_cell(text: "PetalLength", style_attr:"color=black backgroundcolor=white fontweight=bold"); 
      obj.format_cell(text: "PetalWidth", style_attr:"color=black backgroundcolor=white fontweight=bold"); 
      obj.row_end(); 
      obj.head_end(); 
    end;
  ** row for every obs;
	if _type_ = 1 then do;
      obj.row_start(); 
      obj.format_cell(data: species, row_span:1); 
      obj.format_cell(data: sepallength, row_span:1); 
      obj.format_cell(data: sepalwidth, row_span:1); 
      obj.format_cell(data: petallength, row_span:1); 
      obj.format_cell(data: petalwidth, row_span:1); 
	  obj.row_end();
  end;
  if last then do; 
      obj.table_end(); 
  end; 
run; 
ods html close; 
ods pdf close;
ods rtf close;
ods tagsets.rtf close;

title; footnote;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; I used the _TYPE_=1 rows from the PROC MEANS OUTPUT data set because I did not need the _TYPE_=0 row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Depending on the structure of your data and what you need to do, the Report Writing Interface may be an option.&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2024 20:36:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-header-on-top-of-Spanning-Header-in-proc-report/m-p/924916#M364046</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2024-04-18T20:36:56Z</dc:date>
    </item>
    <item>
      <title>Re: Split header on top of Spanning Header in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-header-on-top-of-Spanning-Header-in-proc-report/m-p/924937#M364049</link>
      <description>&lt;P&gt;If you are using JOURNAL style,you could pad some white blanks to mimic this kind of style .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options nonumber nodate;
ods rtf file='c:\temp\temp.rtf' style=journal;
title;
ods escapechar='~';
proc report data=sashelp.class nowd style={outputwidth=100%};
columns name ('~S={borderbottomcolor=black borderbottomwidth=2}(N=41)                              (N=44)'
             ('~S={borderbottomcolor=black borderbottomwidth=2}Overall Post-Baseline'  sex age height weight))
 ;
 run;
 ods rtf close;&lt;/CODE&gt;&lt;/PRE&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="Ksharp_0-1713493880106.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/95677i20DA81533F599509/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1713493880106.png" alt="Ksharp_0-1713493880106.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2024 02:31:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-header-on-top-of-Spanning-Header-in-proc-report/m-p/924937#M364049</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-04-19T02:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: Split header on top of Spanning Header in proc report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Split-header-on-top-of-Spanning-Header-in-proc-report/m-p/925032#M364079</link>
      <description>I like the ease of this approach.  I may try this work around first!</description>
      <pubDate>Fri, 19 Apr 2024 16:24:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Split-header-on-top-of-Spanning-Header-in-proc-report/m-p/925032#M364079</guid>
      <dc:creator>jenim514</dc:creator>
      <dc:date>2024-04-19T16:24:23Z</dc:date>
    </item>
  </channel>
</rss>

