Would you like to try ODS RWI? It gives specific control over which cell should be displayed like what.
It's object orientated language but more like how we write HTML pages without a CSS file.
a sample code that can solve your problem looks like this:
( tweak the code for your dataset names etc., I'm using "work.test" )
To read more about this topic, you can google "ODS RWI" and read the Lex Jensen papers.
ods excel file="your_folder_location/test.xlsx"
options(flow="tables" sheet_name="QSORRES Mapping" absolute_column_width = "22, 23, 16, 60, 60, 13, 60, 65"
frozen_headers='ON' autofilter="ALL");
ods escapechar='~';
data _null_;
set work.test(obs=10) end=done;
/* first two rows */
if _N_ = 1 then do;
declare odsout obj();
obj.table_start();
/* row 1 */
obj.row_start(type:'H');
obj.format_cell(
data:'RAW',
column_span: 4,
just:'C',
style_attr:'background=#E2EFDA');
obj.format_cell(
data:'SDTM',
column_span: 4,
just:'C',
style_attr:'background=#D9E1F2');
obj.row_end();
/* row 2, headers */
obj.row_start(type:'H');
obj.format_cell(data:'FORMNAME_TEST', style_attr:'background=#E2EFDA');
obj.format_cell(data:'FORMNAME_PRODUCTION',style_attr:'background=#E2EFDA');
obj.format_cell(data:'ITEMNAME', style_attr:'background=#E2EFDA');
obj.format_cell(data:'VALUE', style_attr:'background=#E2EFDA');
obj.format_cell(data:'QSORRES', style_attr:'background=#D9E1F2');
obj.format_cell(data:'QSSTRESN', style_attr:'background=#D9E1F2');
obj.format_cell(data:'QSSTRESC', style_attr:'background=#D9E1F2');
obj.format_cell(data:'COMMENTS_SPECIAL_CHARACTERS_', style_attr:'background=#D9E1F2');
obj.row_end();
obj.body_start();
end;
/* starts table body at data row 1, excel row 3 */
obj.row_start();
obj.format_cell(data:FORMNAME_TEST);
obj.format_cell(data:FORMNAME_PRODUCTION);
obj.format_cell(data:ITEMNAME);
obj.format_cell(data:VALUE);
obj.format_cell(data:QSORRES);
obj.format_cell(data:QSSTRESN);
obj.format_cell(data:QSSTRESC);
obj.format_cell(data:COMMENTS_SPECIAL_CHARACTERS_);
obj.row_end();
if done then do;
obj.body_end();
obj.table_end();
end;
run;
ods _all_ close;
Also note that, you need to specify your styles in each "format_cell" method.
Links below to help you quickly get started:
https://support.sas.com/rnd/base/ods/Tipsheet_RWI.pdf
https://www.lexjansen.com/wuss/2019/210_Final_Paper_PDF.pdf
format_cell method link https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/odsadvug/p12q0pykppxbz8n1200luexgbz4t.htm
Hope this helps 🙂
... View more