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,

 

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
Barite | Level 11

what a fix! Thanks a lot.

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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 351 views
  • 0 likes
  • 2 in conversation