So I'm seeing something odd when trying to play with cell borders in a proc report going to an ODS EXCEL output. The client is requesting that some of the cells be merged horizontally--as far as I can tell, I can't do that via SAS, but I figured I could try and fake it with 0-width internal cell borders. This seems to work fine in the internal results viewer, but when transitioned to Excel, any cell with any border attribute defined instead gets completely surrounded.
SAS EG results viewer:
Excel output:
Desired Excel Output:
And my code:
ods excel file="&PDFPath./&&filename_value._&&qvar..xlsx" style=journal options(embedded_titles='yes' embedded_footnotes='yes' sheet_interval='NONE' sheet_name="&qtrvar. Summary" absolute_column_width='26,12,26,12' ); proc report data=source spanrows nowd
style(header)={bordertopwidth=.5 borderbottomwidth=.5
borderleftwidth=.5 borderrightwidth=.5 borderstyle=solid
bordercolor=black};
column ("Level 2" (row1 value1 row2 value2));
define row2 / " " style(column)={width=1000%};
define row1 / " " style(column)={width=1000% bordertopwidth=.5 borderbottomwidth=.5
borderleftwidth=.5 borderrightwidth=.5 borderstyle=solid
bordercolor=black};
define value1 / " " style(column)={width=1000% bordertopwidth=.5 borderbottomwidth=.5
borderleftwidth=.5 borderrightwidth=.5 borderstyle=solid
bordercolor=black};
define value2 / " " style(column)={width=1000% bordertopwidth=0 borderbottomwidth=0
borderleftwidth=0 borderrightwidth=.5 borderstyle=solid
bordercolor=black};
compute value1;
if row1 = 'Target Achieved: Y' then do;
call define('row1', 'style', 'style=[background=lightgreen font_weight=bold just=c]');
call define('value1', 'style', 'style=[background=lightgreen font_weight=bold just=c]');
call define('row2', 'style', 'style=[borderbottomwidth=.5]');
call define('value2', 'style', 'style=[borderbottomwidth=.5]');
end;
else if row1 = 'Target Achieved: N' then do;
call define('row1', 'style', 'style=[background=lightred font_weight=bold just=c]');
call define('value1', 'style', 'style=[background=lightred font_weight=bold just=c]');
call define('row2', 'style', 'style=[borderbottomwidth=.5]');
call define('value2', 'style', 'style=[borderbottomwidth=.5]');
end;
endcomp;
quit; ods excel close;
... View more