Hi SAS community,
I'm trying to highlight certain values within my SAS table. I want to highlight the maximum value for one variable and the minimum value for another variable. For example if I have two variables, var1 and var2, in which I want the maximum value highlighted for var1 and minimum value highlighted for var2, the resulting table will look like:
var1 | var2
---------------
40% | 10%
50% | 20%
60% | 30%
Any help would be appreciated. Thanks!
Proc report builds things from top to bottom left to right.
When you have this column statement:
column var1 var2 maxvar1 minvar2;
Then this compute
compute var1; if var1 = maxvar1 then do; call define (_col_, "style", "style={background=peachpuff}"); end; endcomp;
does not actually have a value of maxvar1 to use since maxvar1 is to the right of var1.
You might try changing the order of variables in the column statement so the maxvars come before var1 and var2.
PROC REPORT allows this.
Hi Paige,
I used PROC SQL to store maximum/minimum values of the variables, but PROC REPORT is still not highlighting the max/min values. Here's a sample of the code:
proc report data=have nowd;
title 'title'
column var1 var2 maxvar1 minvar2;
define var1/display;
define var2/display;
define maxvar1/display noprint;
define minvar2/display noprint;
compute var1;
if var1 = maxvar1 then do;
call define (_col_, "style", "style={background=peachpuff}");
end;
endcomp;
compute var2;
if var2 = minvar2 then do;
call define (_col_, "style", "style={background=peachpuff}");
end;
endcomp;
run;
Proc report builds things from top to bottom left to right.
When you have this column statement:
column var1 var2 maxvar1 minvar2;
Then this compute
compute var1; if var1 = maxvar1 then do; call define (_col_, "style", "style={background=peachpuff}"); end; endcomp;
does not actually have a value of maxvar1 to use since maxvar1 is to the right of var1.
You might try changing the order of variables in the column statement so the maxvars come before var1 and var2.
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 25. Read more here about why you should contribute and what is in it for you!
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.