BookmarkSubscribeRSS Feed
joseph_r91
Calcite | Level 5

So, I'm working on creating a report that highlights cells in a column that meet certain criteria. The issue I'm running into is that when I use the compute block to create the criteria, it is subsequently highlighting all cells in the column on that report instead of only the ones that meet the stated criteria. It could be a formatting issue, but I'm not sure. Any help would be greatly appreciated: 

 

variables - per_change_in_med_rat_incl format = PERCENT9.2

                   - change_limit format= PERCENT9.2

 

So, what I want the report to do is to calculate the absolute value of the percentage in the column per_change_in_med_rat_incl and then check to see if it is greater than the corresponding percentage value in change_limit and to highlight the cell if it meets that criterion:

 

  compute per_change_in_med_rat_incl; 
  if abs(per_change_in_med_rat_incl) > change_limit then 
call define (_col_,'style', 'style=[background=yellow]');
  endcomp;
3 REPLIES 3
PaigeMiller
Diamond | Level 26

Please show us the entire PROC REPORT code that you are using. Please show us (a portion of) your data, provided as working SAS data step code (examples and instructions), do not attach files. Please show us the output you are getting (use the "Insert Photos" icon, do not attach files).

--
Paige Miller
ballardw
Super User

Here is one reason we suggest always including your code, so we don't have to ask basic questions such as: Is the variable Change_limit to the left or right of the variable per_change_in_med_rat_incl in the COLUMN statement?

 

And if you did not provide a Columns statement is the variable column order, check proc contents, greater for Change_limit? That would make it default to right of per_change_in_med_rat_incl.

 

This is important because Proc Report builds reports from left to right. So a variable or value that appears to the right of the current column, per_change_in_med_rat_incl in this case, has undefined or missing values. And in SAS missing is always less than any given value. So if Change_limit is defined to the right it is missing and the comparison:  abs(per_change_in_med_rat_incl) > change_limit  is always true. So all the cells are highlighted.

Tom
Super User Tom
Super User

In addition what every already said how are the referenced columns being used in the PROC REPORT step?

If they are being used as analysis variables then you will not get a value by referencing just the variable name.  You need to also include a statistic.

So perhaps for just the comparator:

if abs(per_change_in_med_rat_incl) > change_limit.sum then 

Or perhaps even for both variables.

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 304 views
  • 2 likes
  • 4 in conversation