<?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: Merge header names in PROC REPORT in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merge-header-names-in-PROC-REPORT/m-p/917500#M361411</link>
    <description>&lt;P&gt;Here is an example for EXCEL destination.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table3way;
  length dmtype durationbi $15;
  infile datalines dlm=',' dsd;
  input dmtype $ ordvar Durationbi $ Num cMean cSTD LowerCL UpperCL Prob_t;
return;
datalines;
"Type 1",1,"&amp;lt;=10 years",17,76.76,17.85,67.59,85.94,0.7243
"Type 1",2,"&amp;gt;10 year",44,75.30,13.06,71.32,79.27,0.7243
"Type 2",1,"&amp;lt;=10 years",47,67.23,22.22,44.44,88.88,0.5584
"Type 2",2,"&amp;gt;10 year",35,69.43,33.33,55.55,99.99,0.5584
;
run;


ods excel file='c:\temp\temp.xlsx';
data _null_; 
  set table3way end=last; 
  by dmtype;
  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: "Type", row_span:2, column_span: 1, style_attr:"vjust=m color=black backgroundcolor=yellow fontweight=bold"); 
      obj.format_cell(text: "Results", column_span:7, style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.row_end(); 
	  ** Header row 2;
      obj.row_start(type: "Header"); 
      obj.format_cell(text: "Durationbi", style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.format_cell(text: "num", style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.format_cell(text: "cmean", style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.format_cell(text: "cstd", style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.format_cell(text: "lowercl",style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.format_cell(text: "uppercl", style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.format_cell(text: "probt",style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.row_end(); 
      obj.head_end(); 
    end;
  ** row for every obs;
  ** treat dmtype and prob_t differently so they span rows;

      obj.row_start(); 
      obj.format_cell(data: dmtype,row_span:1, style_attr:"vjust=m fontweight=bold" ); 
      obj.format_cell(data: Durationbi, row_span:1); 
      obj.format_cell(data: num, row_span:1); 
      obj.format_cell(data: cmean, row_span:1); 
      obj.format_cell(data: cstd, row_span:1); 
      obj.format_cell(data: lowercl, row_span:1); 
      obj.format_cell(data: uppercl, row_span:1); 
      obj.format_cell(data: prob_t, row_span:1, style_attr:"vjust=m fontweight=bold"); 
      obj.row_end(); 
   
  if last then do; 
      obj.table_end(); 
    end; 
run;
footnote;title;
ods excel 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-1708655120061.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/94035i86E37F1F69A42D37/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1708655120061.png" alt="Ksharp_0-1708655120061.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>Fri, 23 Feb 2024 02:25:26 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2024-02-23T02:25:26Z</dc:date>
    <item>
      <title>Merge header names in PROC REPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-header-names-in-PROC-REPORT/m-p/916964#M361188</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=sashelp.class ;
column 
name
('measurements' age sex height weight);
define name /'Name'  
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;that produces the below output:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Zatere_0-1708432332428.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/93939iBF42379D11077DF5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Zatere_0-1708432332428.png" alt="Zatere_0-1708432332428.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I wondered if I could modify the output as:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Zatere_1-1708432402644.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/93940iCFCB824BF4D4FDB7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Zatere_1-1708432402644.png" alt="Zatere_1-1708432402644.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;As you may see, I have merged the header "Name" with the cell above it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help would much be appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2024 12:34:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-header-names-in-PROC-REPORT/m-p/916964#M361188</guid>
      <dc:creator>Zatere</dc:creator>
      <dc:date>2024-02-20T12:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: Merge header names in PROC REPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-header-names-in-PROC-REPORT/m-p/916969#M361191</link>
      <description>Hi:&lt;BR /&gt;  PROC REPORT does not merge headers vertically, as you show in your screen shot.  &lt;BR /&gt;Cynthia</description>
      <pubDate>Tue, 20 Feb 2024 13:19:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-header-names-in-PROC-REPORT/m-p/916969#M361191</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2024-02-20T13:19:18Z</dc:date>
    </item>
    <item>
      <title>Re: Merge header names in PROC REPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-header-names-in-PROC-REPORT/m-p/917296#M361332</link>
      <description>You could try RWI skill.&lt;BR /&gt;Here is an example:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-create-report-with-varying-column-and-row-numbers-using/m-p/907985" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/How-to-create-report-with-varying-column-and-row-numbers-using/m-p/907985&lt;/A&gt;</description>
      <pubDate>Thu, 22 Feb 2024 03:06:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-header-names-in-PROC-REPORT/m-p/917296#M361332</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-02-22T03:06:11Z</dc:date>
    </item>
    <item>
      <title>Re: Merge header names in PROC REPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-header-names-in-PROC-REPORT/m-p/917364#M361375</link>
      <description>Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;, yes, RWI is a possibility. I did not mention it because the original question did not specify what destinations in ODS they were using with their code.&lt;BR /&gt;Cynthia</description>
      <pubDate>Thu, 22 Feb 2024 14:07:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-header-names-in-PROC-REPORT/m-p/917364#M361375</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2024-02-22T14:07:47Z</dc:date>
    </item>
    <item>
      <title>Re: Merge header names in PROC REPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-header-names-in-PROC-REPORT/m-p/917379#M361381</link>
      <description>&lt;P&gt;How would it be possible to move the "Name" into the first line?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2024 15:32:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-header-names-in-PROC-REPORT/m-p/917379#M361381</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-02-22T15:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: Merge header names in PROC REPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-header-names-in-PROC-REPORT/m-p/917382#M361382</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could phrase it like that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If possible, the end result would be like the below:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Zatere_0-1708616290230.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/94006i84FA6DFEFB068AC9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Zatere_0-1708616290230.png" alt="Zatere_0-1708616290230.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;If one would do it in excel, they would just merge the two rows to put into the "Name".&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2024 15:40:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-header-names-in-PROC-REPORT/m-p/917382#M361382</guid>
      <dc:creator>Zatere</dc:creator>
      <dc:date>2024-02-22T15:40:42Z</dc:date>
    </item>
    <item>
      <title>Re: Merge header names in PROC REPORT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merge-header-names-in-PROC-REPORT/m-p/917500#M361411</link>
      <description>&lt;P&gt;Here is an example for EXCEL destination.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table3way;
  length dmtype durationbi $15;
  infile datalines dlm=',' dsd;
  input dmtype $ ordvar Durationbi $ Num cMean cSTD LowerCL UpperCL Prob_t;
return;
datalines;
"Type 1",1,"&amp;lt;=10 years",17,76.76,17.85,67.59,85.94,0.7243
"Type 1",2,"&amp;gt;10 year",44,75.30,13.06,71.32,79.27,0.7243
"Type 2",1,"&amp;lt;=10 years",47,67.23,22.22,44.44,88.88,0.5584
"Type 2",2,"&amp;gt;10 year",35,69.43,33.33,55.55,99.99,0.5584
;
run;


ods excel file='c:\temp\temp.xlsx';
data _null_; 
  set table3way end=last; 
  by dmtype;
  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: "Type", row_span:2, column_span: 1, style_attr:"vjust=m color=black backgroundcolor=yellow fontweight=bold"); 
      obj.format_cell(text: "Results", column_span:7, style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.row_end(); 
	  ** Header row 2;
      obj.row_start(type: "Header"); 
      obj.format_cell(text: "Durationbi", style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.format_cell(text: "num", style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.format_cell(text: "cmean", style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.format_cell(text: "cstd", style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.format_cell(text: "lowercl",style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.format_cell(text: "uppercl", style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.format_cell(text: "probt",style_attr:"color=black backgroundcolor=cxdddddd fontweight=bold"); 
      obj.row_end(); 
      obj.head_end(); 
    end;
  ** row for every obs;
  ** treat dmtype and prob_t differently so they span rows;

      obj.row_start(); 
      obj.format_cell(data: dmtype,row_span:1, style_attr:"vjust=m fontweight=bold" ); 
      obj.format_cell(data: Durationbi, row_span:1); 
      obj.format_cell(data: num, row_span:1); 
      obj.format_cell(data: cmean, row_span:1); 
      obj.format_cell(data: cstd, row_span:1); 
      obj.format_cell(data: lowercl, row_span:1); 
      obj.format_cell(data: uppercl, row_span:1); 
      obj.format_cell(data: prob_t, row_span:1, style_attr:"vjust=m fontweight=bold"); 
      obj.row_end(); 
   
  if last then do; 
      obj.table_end(); 
    end; 
run;
footnote;title;
ods excel 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-1708655120061.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/94035i86E37F1F69A42D37/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1708655120061.png" alt="Ksharp_0-1708655120061.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>Fri, 23 Feb 2024 02:25:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merge-header-names-in-PROC-REPORT/m-p/917500#M361411</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-02-23T02:25:26Z</dc:date>
    </item>
  </channel>
</rss>

