proc report data=sashelp.class nowd;
*Color whole column;
compute age;
call define(_col_,"style","style={background=gray}");
endcomp;
*color rule 1;
define Height/display;
compute Height;
if Height<60 then call define(_col_,"style","style={background=red}");
endcomp;
*color rule 2;
define Weight/display;
compute Weight;
if Weight<100 then call define(_col_,"style","style={background=Yellow}");
endcomp;
run;
*Color the whole row;
proc report data=sashelp.class nowd ;
define Age/display;
compute Age;
if Age > 15 then call define(_row_,"style","style={background=Red}");
endcomp;
run;
data have;
input n a b;
datalines;
1 2 .
2 3 1
3 0 1
4 -2 .
5 4 -1
;run;
proc report data=have nowd;
column n a b ;
define n/display;
define a/display;
define b/display;
compute b; /*if you need to check a condition, COMPUTE the last column to the right*/
if a>0 and b=1 then do;
do i = 2 to 3; /*column to color*/
call define(i, "style","style={background=light greenish yellow}");
end;
end;
endcomp;
run;
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.