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.
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!
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.