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;
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 lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.