<?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: Selective Horizontal Cell Merging in ExcelXP? in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Selective-Horizontal-Cell-Merging-in-ExcelXP/m-p/445318#M20623</link>
    <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect you're right that selective horizontal merging isn't possible, at least for now.&amp;nbsp; I can get the mergeacross into the XML, but SAS appears to not be generating&amp;nbsp;whatever accompanying XML is needed to support the mergeacross.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I could try switching from ExcelXP to Excel, but I'm sort of hoping that&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt;&amp;nbsp;will weigh in if she has time.&amp;nbsp; She's typically got a pretty good handle on what it is that ODS can and cannot do.&amp;nbsp; I'd hate to burn through a lot of time working on something that just can't be done.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
    <pubDate>Tue, 13 Mar 2018 21:06:48 GMT</pubDate>
    <dc:creator>jimbarbour</dc:creator>
    <dc:date>2018-03-13T21:06:48Z</dc:date>
    <item>
      <title>Selective Horizontal Cell Merging in ExcelXP?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Selective-Horizontal-Cell-Merging-in-ExcelXP/m-p/445303#M20620</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm running SAS 9.4 (9.4 TS1M4) on AIX with Enterprise Guide 7.15 HF2 as a front end.&amp;nbsp;&amp;nbsp;I'm creating a spreadsheet using the ODS ExcelXP tagset.&amp;nbsp; I want to&amp;nbsp;&lt;EM&gt;selectively&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;merge cells in columns 6, 7, and 8 together whenever a certain value appears in the cell in column 5.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;BOTTOM LINE UP FRONT&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(with background and code below):&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Can SAS with ODS ExcelXP support the generation of XML to&amp;nbsp;&lt;EM&gt;selectively&lt;/EM&gt;&amp;nbsp;merge cells or is it all or nothing?&amp;nbsp; In other words, must I choose between having columns 6, 7, and 8&amp;nbsp;&lt;EM&gt;always&lt;/EM&gt;&amp;nbsp;merged on every row or can I&amp;nbsp;&lt;EM&gt;selectively&lt;/EM&gt;&amp;nbsp;merge columns 6, 7, and 8 with some rows having the columns merged and some rows with those same columns not merged?&amp;nbsp; XML clearly can support selective merging, but can SAS ODS ExcelXP?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's my code.&amp;nbsp; Note the use of the TAGATTR with a "mergeacross".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	**	If the cell contains a label, bold the cell.	**;
	**	For Payment Pattern 82 (in column 5), merge column 6 across columns 7 and 8.	**;
	COMPUTE	Column6;
		IF	SUBSTR(Column6,LENGTH(Column6), 1)		=	":"	THEN
			CALL DEFINE	( _col_,'style','style=[FONT=("Calibri",8pt,Bold)]');
		ELSE
		IF	STRIP(Column5)							=	'Pmt Pttrn82 25/25/32:'	THEN
			CALL DEFINE	( _col_,'style','style=[tagattr="mergeacross:2"]');	
	ENDCOMP;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following XML is generated if a given row has 'Pmt Pttrn82 25/25/32:' in column 5.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&amp;lt;Row ss:AutoFitHeight="1" ss:Height="14"&amp;gt;
&amp;lt;Cell ss:StyleID="data_4" ss:Index="1"&amp;gt;&amp;lt;Data ss:Type="String"&amp;gt;Pmt Pattern Dt (m):&amp;lt;/Data&amp;gt;&amp;lt;/Cell&amp;gt;
&amp;lt;Cell ss:StyleID="data" ss:Index="2"&amp;gt;&amp;lt;Data ss:Type="String"&amp;gt;08/23/2016 (13)&amp;lt;/Data&amp;gt;&amp;lt;/Cell&amp;gt;
&amp;lt;Cell ss:StyleID="data" ss:Index="3"&amp;gt;&amp;lt;Data ss:Type="String"&amp;gt;&amp;lt;/Data&amp;gt;&amp;lt;/Cell&amp;gt;
&amp;lt;Cell ss:StyleID="data" ss:Index="4"&amp;gt;&amp;lt;Data ss:Type="String"&amp;gt;&amp;lt;/Data&amp;gt;&amp;lt;/Cell&amp;gt;
&amp;lt;Cell ss:StyleID="data_5" ss:Index="5"&amp;gt;&amp;lt;Data ss:Type="String"&amp;gt;Pmt Pttrn82 25/25/32:&amp;lt;/Data&amp;gt;&amp;lt;/Cell&amp;gt;
&amp;lt;Cell ss:StyleID="data" ss:MergeAcross="2" ss:Index="6"&amp;gt;&amp;lt;Data ss:Type="String"&amp;gt;----+----1----+----2----+&amp;lt;/Data&amp;gt;&amp;lt;/Cell&amp;gt;
&amp;lt;Cell ss:StyleID="data" ss:Index="7"&amp;gt;&amp;lt;Data ss:Type="String"&amp;gt;&amp;lt;/Data&amp;gt;&amp;lt;/Cell&amp;gt;
&amp;lt;Cell ss:StyleID="data_6" ss:Index="8"&amp;gt;&amp;lt;Data ss:Type="String"&amp;gt;&amp;lt;/Data&amp;gt;&amp;lt;/Cell&amp;gt;
&amp;lt;/Row&amp;gt;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately, Excel can't open the XML.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I remove the mergeacross in my SAS program and re-run, Excel can open the SAS generated XML, but of course my cells aren't merged.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I do the merge manually on the same spreadsheet (after a SAS run with the mergeacross removed), the following XML is created by Excel when I save the spreadsheet:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;   &amp;lt;Row ss:AutoFitHeight="0" ss:Height="14.0625"&amp;gt;
    &amp;lt;Cell ss:StyleID="s67"&amp;gt;&amp;lt;Data ss:Type="String"&amp;gt;Pmt Pattern Dt (m):&amp;lt;/Data&amp;gt;&amp;lt;/Cell&amp;gt;
    &amp;lt;Cell ss:StyleID="s68"&amp;gt;&amp;lt;Data ss:Type="String"&amp;gt;08/23/2016 (13)&amp;lt;/Data&amp;gt;&amp;lt;/Cell&amp;gt;
    &amp;lt;Cell ss:StyleID="s68"&amp;gt;&amp;lt;Data ss:Type="String"&amp;gt;&amp;lt;/Data&amp;gt;&amp;lt;/Cell&amp;gt;
    &amp;lt;Cell ss:StyleID="s68"&amp;gt;&amp;lt;Data ss:Type="String"&amp;gt;&amp;lt;/Data&amp;gt;&amp;lt;/Cell&amp;gt;
    &amp;lt;Cell ss:StyleID="s69"&amp;gt;&amp;lt;Data ss:Type="String"&amp;gt;Pmt Pttrn82 25/25/32:&amp;lt;/Data&amp;gt;&amp;lt;/Cell&amp;gt;
    &amp;lt;Cell ss:MergeAcross="2" ss:StyleID="m313941736"&amp;gt;&amp;lt;Data ss:Type="String"&amp;gt;&amp;amp;#45;&amp;amp;#45;&amp;amp;#45;-+&amp;amp;#45;&amp;amp;#45;&amp;amp;#45;-1&amp;amp;#45;&amp;amp;#45;&amp;amp;#45;-+&amp;amp;#45;&amp;amp;#45;&amp;amp;#45;-2&amp;amp;#45;&amp;amp;#45;&amp;amp;#45;-+&amp;lt;/Data&amp;gt;&amp;lt;/Cell&amp;gt;
   &amp;lt;/Row&amp;gt;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The XML immediately above saves and re-opens just fine, and the cells are merged the way I want them to be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, you may be saying to yourself "duh, Jim, you have XML for columns 7 and 8 in the SAS generated version."&amp;nbsp; True, but even when I remove the XML for columns 7 and 8, Excel still can't open it.&amp;nbsp; There's something else going on.&amp;nbsp; The XML specifically for the merge (ss:MergeAcross="2") across looks fine.&amp;nbsp; The only difference that I see right off in the row code is that a new StyleID has been introduced in the XML that Excel created after I merged the cells manually.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also notice that the table tag is different when I save manually vs. what SAS generates.&lt;/P&gt;
&lt;P&gt;SAS version:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&amp;lt;Table ss:StyleID="_body"&amp;gt;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Excel version:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;  &amp;lt;Table ss:ExpandedColumnCount="8" ss:ExpandedRowCount="1080" x:FullColumns="1"
   x:FullRows="1" ss:StyleID="s62" ss:DefaultRowHeight="15"&amp;gt;
&lt;/PRE&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;So, to reiterate the questions posed in the beginning of this post:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Can SAS with&amp;nbsp;ODS ExcelXP support the generation of XML to&amp;nbsp;&lt;EM&gt;selectively&lt;/EM&gt;&amp;nbsp;merge cells or is it all or nothing?&amp;nbsp; In other words, must I choose between having, say, columns 6, 7, and 8&amp;nbsp;&lt;EM&gt;always&lt;/EM&gt;&amp;nbsp;merged on every row or can I&amp;nbsp;&lt;EM&gt;selectively&lt;/EM&gt;&amp;nbsp;merge columns 6, 7, and 8 with some rows having the columns merged and some rows with those same columns not merged?&amp;nbsp; XML clearly can support selective merging, but can SAS ODS ExcelXP?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Jim&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Mar 2018 20:41:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Selective-Horizontal-Cell-Merging-in-ExcelXP/m-p/445303#M20620</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2018-03-13T20:41:28Z</dc:date>
    </item>
    <item>
      <title>Re: Selective Horizontal Cell Merging in ExcelXP?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Selective-Horizontal-Cell-Merging-in-ExcelXP/m-p/445307#M20621</link>
      <description>&lt;P&gt;Have you tried a similar approach with ODS EXCEL instead?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I suspect this isn't possible &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Mar 2018 20:46:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Selective-Horizontal-Cell-Merging-in-ExcelXP/m-p/445307#M20621</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-13T20:46:21Z</dc:date>
    </item>
    <item>
      <title>Re: Selective Horizontal Cell Merging in ExcelXP?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Selective-Horizontal-Cell-Merging-in-ExcelXP/m-p/445318#M20623</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect you're right that selective horizontal merging isn't possible, at least for now.&amp;nbsp; I can get the mergeacross into the XML, but SAS appears to not be generating&amp;nbsp;whatever accompanying XML is needed to support the mergeacross.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I could try switching from ExcelXP to Excel, but I'm sort of hoping that&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt;&amp;nbsp;will weigh in if she has time.&amp;nbsp; She's typically got a pretty good handle on what it is that ODS can and cannot do.&amp;nbsp; I'd hate to burn through a lot of time working on something that just can't be done.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Tue, 13 Mar 2018 21:06:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Selective-Horizontal-Cell-Merging-in-ExcelXP/m-p/445318#M20623</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2018-03-13T21:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: Selective Horizontal Cell Merging in ExcelXP?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Selective-Horizontal-Cell-Merging-in-ExcelXP/m-p/445345#M20624</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Well, thanks for the vote of confidence. Alas, I do not think you get to there using PROC REPORT. However, while I can't guarantee that ODS EXCEL will use the Report Writing Interface all the time as you want, I was able to modify one of the programs from my "Elvis" paper using SASHELP.IRIS to show both column spanning and row spanning selectively.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Here's the example in HTML compared to ODS EXCEL:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="using_rwi.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/19174i9E2B8408E82DDBF7/image-size/large?v=v2&amp;amp;px=999" role="button" title="using_rwi.png" alt="using_rwi.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;And, here's the code I used:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc sort data=sashelp.iris out=iris;
  by Species;
run;
ods listing close; 


ods html path='c:\temp' file="complex_5_iris.html";
ods pdf file="c:\temp\complex_5_iris.pdf";
ods excel file="c:\temp\complex_5_iris.xlsx" ;

title "Example 3) Row and Column Spanning";
data _null_; 
  set IRIS end=last; 
  by species;
  length longvar $100;
  if first.species then do;
     spc_cnt = 0;
     sl_tot = 0;
     sw_tot = 0;
     pl_tot = 0;
     pw_tot = 0;
  end;
  spc_cnt + 1;
  sl_tot + SepalLength;
  sw_tot + sepalwidth;
  pl_tot + PetalLength;
  pw_tot + PetalWidth;
  if last.species then do;
     sl_avg = sl_tot / spc_cnt;
     sw_avg = sw_tot / spc_cnt;
     pl_avg = pl_tot / spc_cnt;
     pw_avg = pw_tot / spc_cnt;
  end;
  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: "Averages by Species", column_span:5, style_attr:"color=black backgroundcolor=CXd98cb3"); 
      obj.row_end(); 
      ** Header row 2;
      obj.row_start(type: "Header"); 
      obj.format_cell(text: "Species", style_attr:"color=black backgroundcolor=CXd98cb3 fontweight=bold"); 
      obj.format_cell(text: "SepalLength", style_attr:"color=black backgroundcolor=CXd98cb3 fontweight=bold"); 
      obj.format_cell(text: "SepalWidth", style_attr:"color=black backgroundcolor=CXd98cb3 fontweight=bold"); 
      obj.format_cell(text: "PetalLength", style_attr:"color=black backgroundcolor=CXd98cb3 fontweight=bold"); 
      obj.format_cell(text: "PetalWidth", style_attr:"color=black backgroundcolor=CXd98cb3 fontweight=bold"); 
      obj.row_end(); 
      obj.head_end(); 
    end;
  ** row for every obs;
	if last.species then do;
      obj.row_start(); 
	  if species eq 'Setosa' then do;
        obj.format_cell(data: species, row_span:1 ); 
        obj.format_cell(data: sl_avg, row_span:1); 
        obj.format_cell(data: sw_avg, row_span:1); 
        obj.format_cell(data: pl_avg, row_span:2,style_attr:"vjust=m"); 
        obj.format_cell(data: pw_avg, row_span:1); 
	  end;
      else if species eq 'Versicolor' then do;
        obj.format_cell(data: species, row_span:1 ); 
        obj.format_cell(data: sl_avg, row_span:1, column_span:2); 
        ** do not write pl_avg for Versicolor; 
        obj.format_cell(data: pw_avg, row_span:1); 
	  end;
	  else if species eq 'Virginica' then do;
        obj.format_cell(data: species, row_span:1 ); 
        obj.format_cell(data: sl_avg, row_span:1); 
        obj.format_cell(data: sw_avg, row_span:1); 
        obj.format_cell(data: pl_avg, row_span:1); 
        obj.format_cell(data: pw_avg, row_span:1); 
	  end;
      obj.row_end();
  end;
  if last then do; 
      obj.table_end(); 
  end; 
run; 
ods _all_ close; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hope that helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Tue, 13 Mar 2018 22:22:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Selective-Horizontal-Cell-Merging-in-ExcelXP/m-p/445345#M20624</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2018-03-13T22:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: Selective Horizontal Cell Merging in ExcelXP?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Selective-Horizontal-Cell-Merging-in-ExcelXP/m-p/445351#M20625</link>
      <description>&lt;P&gt;Ah.&amp;nbsp; Now that's nice.&amp;nbsp; I will try that.&amp;nbsp; Thank you,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Tue, 13 Mar 2018 22:52:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Selective-Horizontal-Cell-Merging-in-ExcelXP/m-p/445351#M20625</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2018-03-13T22:52:46Z</dc:date>
    </item>
  </channel>
</rss>

