BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mzhao
Calcite | Level 5

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!

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.

 

View solution in original post

3 REPLIES 3
mzhao
Calcite | Level 5

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;

 

ballardw
Super User

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.

 

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 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

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
  • 3065 views
  • 2 likes
  • 3 in conversation