BookmarkSubscribeRSS Feed
Ronein
Onyx | Level 15
Hello
Let's say that I have a data set that included summary information by customers grade.

Let's say that there is a macro variable called colorgrade and the task is to color the row with the chosen grade in red color.

What is the way to do it please?

%let colorgrade=10;
Data have;
Input grade nr obligo2205 obligo2204;
Cards:
2 80000 200 220
3 70000 190 210
4 200000 400 370
5 250000 500 480
6 280000 520 510
7 180000 280 320
8 140000 210 215
9 90000 140 130
10 30000 90 92
;
Run;
2 REPLIES 2
andreas_lds
Jade | Level 19

It is not possible to change the background colour of a row in a dataset.

 

Edit: If you want a report, using proc report would be my first choice. There are many papers explaining how to change the background colour conditionally, i am sure you will find something adaptable to your issue.

Ksharp
Super User
%let colorgrade=10;
Data have;
Input grade nr obligo2205 obligo2204;
Cards;
2 80000 200 220
3 70000 190 210
4 200000 400 370
5 250000 500 480
6 280000 520 510
7 180000 280 320
8 140000 210 215
9 90000 140 130
10 30000 90 92
;
Run;

proc report data=have nowd;
define grade/display;
compute grade;
if grade=&colorgrade. then call define(_row_,'style','style={background=red}');
endcomp;
run;

Ksharp_0-1659530792079.png

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 847 views
  • 0 likes
  • 3 in conversation