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;
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;
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;
what a fix! Thanks a lot.
I am still curious as to why no print ID mess the code up.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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 save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.