BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
prsr
Fluorite | Level 6

Hi there, 

 

Pls assist, thanks in advance.

 

I am applying colour coding based on the % of status (status has 3 categories in it - Planned, Completed, Overdue). Now the rules are applied as a whole. Is there a way to include colour coding by status.

current scenario:

If status:

95% - 100% green

75% - <95% amber

<75% red

 

Is it possible to apply rules based on status:

if status="Completed" and percentage ge 75% then green.

if status="Overdue" and percentage le 5% then green.

...and so on.

prsr_0-1719582471377.png

 

Thanks,

RP

 

1 ACCEPTED SOLUTION

Accepted Solutions
Stu_SAS
SAS Employee

Hey @prsr! I believe you can achieve this by creating a calculated item that flags a 1 or 0 if the aggregated value is higher than the expected value for that specific category. Let's consider this with sashelp.cars: we have a bar chart with average horsepower by origin. If the average horsepower for Asian vehicles is > 150, we want the bar to be red. Let's create a calculation that does this:

 

if( Avg(ByGroup, if(Origin = 'Asia') return Horsepower else .) ) > 150
    return 1
else 0

 

Now we can add this calculation as a rule to our bar chart. Based on our calculation, this can only be a 1 or 0 for Asian vehicles.

Stu_SAS_0-1719588422497.png

 

And now if we look at our bar chart, only Asia is highlighted red.

Stu_SAS_1-1719588598615.png

 

 

View solution in original post

2 REPLIES 2
Stu_SAS
SAS Employee

Hey @prsr! I believe you can achieve this by creating a calculated item that flags a 1 or 0 if the aggregated value is higher than the expected value for that specific category. Let's consider this with sashelp.cars: we have a bar chart with average horsepower by origin. If the average horsepower for Asian vehicles is > 150, we want the bar to be red. Let's create a calculation that does this:

 

if( Avg(ByGroup, if(Origin = 'Asia') return Horsepower else .) ) > 150
    return 1
else 0

 

Now we can add this calculation as a rule to our bar chart. Based on our calculation, this can only be a 1 or 0 for Asian vehicles.

Stu_SAS_0-1719588422497.png

 

And now if we look at our bar chart, only Asia is highlighted red.

Stu_SAS_1-1719588598615.png

 

 

prsr
Fluorite | Level 6

Hi @Stu_SAS, Thanks for your time assisting on this.

I have the below data structure:

prsr_0-1719769783306.png

1 – status , directly from SAS table

2 – count , directly from SAS table

3 – % calculated data item – aggregate measure created as below

Sum [_ByGroup_] ('count'n) / Sum [_ForAll_] ('count'n)

Format Percentage applied

4 – % calculated data item as above, but with out percentage format

In your example, both the fields already in sas table. I tried to replicate the example on on sas sample cars table and it worked. In my case (table structure above), I have to use % field (calculated data item – Aggregated measure) in conjunction with status. Is it possible to use one field that is part of the sas table (…status) and another an aggregate measure (%) together in an expression to my requirement to colour bar chart – bar (overdue) and % >0.003.

 

I tried below expressions using calculated item Aggregate measure %–

IF ( Sum [_ByGroup_] ((

IF ( UpCase('Status'n) = 'OVERDUE' )

RETURN '%'n

ELSE . )) > 0.001 )

RETURN 1

ELSE 0

 

 

(IF ('STATUS'n ='Overdue') return ((sum [_ByGroup_] ('%_num'n)) ELSE .) >0.002 )

return 1

else .

 

Thanks, 

RP

 

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!

Tips for filtering data sources in SAS Visual Analytics

See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 522 views
  • 1 like
  • 2 in conversation