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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

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