ODS and Base Reporting

Build reports by using ODS to create HTML, PDF, RTF, Excel, text reports and more!
BookmarkSubscribeRSS Feed
haesol42
Calcite | Level 5

Hello, 

 

I am trying to make a report that that highlights some cells in a table. 

I have a matrix (say IND) that contains column and row indices created in iml, and pass it to proc template routine to hightlight the cells that correspond to IND.

 

For example: 

 

proc template;
define table CustomColor;
cellstyle 
_COL_ = "want to place column index from IND" && _ROW_ = "want to place row index from IND" as {backgroundcolor=LightRed};
end;
run;
 
 
proc iml;
tbl = TableCreateFromDataSet("Sashelp", "Class");
IND = {2 3,
             4 2
             5 4};
/% this means that I want to hightlight the matrix elements indexed by (2,3), (4,2) and (5,4). And the matrix IND is not hard-coded in practice. %/
call TablePrint(tbl) numobs=6
template="CustomColor";
quit;

 

How can I write a program that template picks up the values defined in IND, and paint the cells properly?

 

Thank you. 

1 REPLY 1
Bari_sas
SAS Employee

PROC TEMPLATE's CELLSTYLE AS can be helpful here, but you will need to code your ROW / COLUMN combinations in PROC TEMPLATE, not IML. Here's an example:


ods path work.template(update) sashelp.tmplmst;

proc template;
define table Checkerboard;
cellstyle _row_=2 && _col_=3 as data{backgroundcolor=yellow fontweight=bold },
_row_=4 && _col_=2 as data{backgroundcolor=yellow fontweight=bold },
_row_=5 && _col_=4 as data{backgroundcolor=yellow fontweight=bold },
1 as data;
end;
run;

ods trace on;
proc iml;
tbl = TableCreateFromDataSet("Sashelp", "Class");
IND = {2 3,
4 2,
5 4};
call TablePrint(tbl) numobs=6
template="Checkerboard"
;
quit;

 

Here are my results from SAS 9.4m8:

Bari_sas_0-1700169698941.png

 

 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 811 views
  • 3 likes
  • 2 in conversation