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

Hi Everyone,

 

When I don't print the column ID, the coloring turn wrong.

Can you help me to fix it?

 

Thank you,

 

HHCFX

 

data have;
input id v1 v2;
datalines;
1 2 3
2 2 2
2 2 1
2 0 0
3 1 1
3 1 0
;run;


proc report data=have nowd;

	define id/display;		*Display ID --> CORRECT COLORING;
	define v1/display;
	define v2/display;

	compute id  ;
		IF id=1 then call define(_row_,'style','style={background=VLIGB}'); ELSE
		IF id=2 then call define(_row_,'style','style={background=LIGGR}'); ELSE
		IF id=3 then call define(_row_,'style','style={background=TAN}'); 
	endcomp;
run;

proc report data=have nowd;

	define id/order noprint;	*NO Display ID --> WRONG COLORING;
	define v1/display;
	define v2/display;

	compute id  ;
		IF id=1 then call define(_row_,'style','style={background=VLIGB}'); ELSE
		IF id=2 then call define(_row_,'style','style={background=LIGGR}'); ELSE
		IF id=3 then call define(_row_,'style','style={background=TAN}'); 
	endcomp;
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

A bit of a kludge but his seems to work:


proc report data=HAVE nowd;

	define ID/order noprint;	*NO Display ID --> WRONG COLORING;
	define V1/display;
	define V2/display;

	compute before ID  ; 
	    A=ID;
	endcomp;
 	compute ID ;
		if A=1 then call define(_row_,'style','style={background=VLIGB}'); ELSE
		if A=2 then call define(_row_,'style','style={background=LIGGR}'); ELSE
		if A=3 then call define(_row_,'style','style={background=TAN}'); 
	endcomp;
run;

 

View solution in original post

2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

A bit of a kludge but his seems to work:


proc report data=HAVE nowd;

	define ID/order noprint;	*NO Display ID --> WRONG COLORING;
	define V1/display;
	define V2/display;

	compute before ID  ; 
	    A=ID;
	endcomp;
 	compute ID ;
		if A=1 then call define(_row_,'style','style={background=VLIGB}'); ELSE
		if A=2 then call define(_row_,'style','style={background=LIGGR}'); ELSE
		if A=3 then call define(_row_,'style','style={background=TAN}'); 
	endcomp;
run;

 

hhchenfx
Rhodochrosite | Level 12

what a fix! Thanks a lot.

I am still curious as to why no print ID mess the code up.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 650 views
  • 0 likes
  • 2 in conversation