BookmarkSubscribeRSS Feed
LukeL
Obsidian | Level 7

Hi all,

I need to put a matrix on a pdf, and need to color some cells of the diagonal of it, and I'm wondering if there is an easy way, without the need to count all the columns and make lot of pre-computations.

A the end, I have a proc report like this

proc report data=MATRIX_TABLE missin;
    columns REGION_A VALUE,REGION_B;
    define REGION_A / group;
    define REGION_B / across '';
    define VALUE / analysis;
run;

and need to higlight (background color/text/etc) only the cells that have equal values for REGION_A/B (not always present).

Any idea I'm missing?

 

Thanks!

3 REPLIES 3
PaigeMiller
Diamond | Level 26

Yes, there are a lot of ways to color backgrounds of cells in PROC REPORT, and I'm sure Google will find so many you can't read them all. 

 

Coloring the background of diagonal cells is something I have not done, and seems to me you might need a macro to determine the exact list of levels of REGION_A and REGION_B and then find out when you are in the (1,1) cell and the (2,2) cell and so on, and run this macro in the COMPUTE block of PROC REPORT. If (additional complication) the list of values of REGION_A and REGION_B changes from one run of PROC REPORT on data set1 to the next run of PROC REPORT on data set 2, then you will definitely need a macro.

--
Paige Miller
Cynthia_sas
SAS Super FREQ
Hi:
It would be swell if you posted some data so folks could fiddle with your code without having to make assumptions about what the data looked like.
Cynthia
Cynthia_sas
SAS Super FREQ

Hi:

  With some fake data that represented an "even" matrix of 4 values for the rows and 4 values for the columns, I was able to use of PROC REPORT with a temporary variable to do the highlighting on the diagonal, as shown below:

Cynthia_sas_0-1600452961230.png

 

 

Note that this method will only work with an "even" matrix. If Region_A had 4 values, but Region_B had 5 values, then the logic of the COMPUTE block would not work.

Cynthia_sas_1-1600453006323.png

But, then, there's no really a diagonal to highlight for the EEE value, so I would assume that's OK.

 

Cynthia

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1040 views
  • 0 likes
  • 3 in conversation