Hello
I am using proc report.
I want to color entire rows based on values in 2 columns.
I understand that "compute age Sex" is wrong but what is the way to solve it?
proc report data=sashelp.class nowd;
column name age sex height weight;
define name / display;
define age / display;
define sex / order;
define height / sum;
define weight / sum;
compute age Sex;
if age <= 12 AND Sex='M' then
call define(_row_,"style","style={background=blue}");
else if 12< AND Sex='F' then
call define(_row_,"style","style={background=red}");
endcomp;
run;
You have to change "order" to "display" and use variable "Sex" to get the desired output:
proc report data=sashelp.class;
column name age sex height weight;
define name / display;
define age / display;
define sex / display;
define height / sum;
define weight / sum;
compute Sex;
if Age <= 12 AND Sex = 'M' then do;
call define(_row_,"style","style={background=blue}");
end;
else do;
if 12 < Age AND Sex='F' then do;
call define(_row_,"style","style={background=red}");
end;
end;
endcomp;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.