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

 

Hi Everyone,

Can you help me with this color code?

it works if I want to color '_c2_'.

Thank you,

HHCFX

 

data a;
input name $ v1 v2 v3;
datalines;
a 1 2 1
a 3 4 1
b 4 5 3
b 3 5 8
b 1 1 5
c 1 1 5
c 0 0 5
run;

proc report data=a nowd;

		define name/display;
		define v1/display;
		define v2/display;
		define v3/display;

		compute v1  ;
			if v1>2 then call define('_c3_',"style","style={background=BIYG}");
			else
			 call define('_c3_',"style","style={background=LIGY}");
			endcomp;
		run;

 

proc report data=a nowd;
		column name v1 v2 v3;
		define name/display;
		define v1/display;
		define v2/display;
		define v3/display;

compute v3  ;
			if v1>2 and 3<v2<=5 then call define(_col_,"style","style={background=BIYG}");
			else
			if v1>=1 and v2 <4 then call define(_col_,"style","style={background=LIGY}");
			endcomp;
run;  

 

SOLUTION 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
compute v3  ;
	if v1>2 then 
		call define(_col_,"style","style=[background=grey]");
	else
		call define(_col_,"style","style=[background=lightpink]");
endcomp;

You can reference a different variable in your logic. I think this works for what you want.

View solution in original post

4 REPLIES 4
Reeza
Super User
compute v3  ;
	if v1>2 then 
		call define(_col_,"style","style=[background=grey]");
	else
		call define(_col_,"style","style=[background=lightpink]");
endcomp;

You can reference a different variable in your logic. I think this works for what you want.

hhchenfx
Barite | Level 11

  

Your code run. 

 

 

proc report data=a nowd;
		column name v1 v2 v3;
		define name/display;
		define v1/display;
		define v2/display;
		define v3/display;

compute v3  ;
			if v1>2 and 3<v2<=5 then call define(_col_,"style","style={background=BIYG}");
			else
			if v1>=1 and v2 <4 then call define(_col_,"style","style={background=LIGY}");
			endcomp;
run;  

 

Reeza
Super User
Works fine for me. Your second condition is never met though, is it? So there's a few records colored grey. I did remove the v4 because it just adds an empty column.
hhchenfx
Barite | Level 11

Yes. Thank you.

My bad.

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 16. 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
  • 4 replies
  • 652 views
  • 1 like
  • 2 in conversation