🔒 This topic is solved and locked.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 12-14-2018 12:07 PM
(812 views)
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
4 REPLIES 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yes. Thank you.
My bad.