BookmarkSubscribeRSS Feed
Ronein
Onyx | Level 15

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;

 

 

1 REPLY 1
andreas_lds
Jade | Level 19

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;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 709 views
  • 0 likes
  • 2 in conversation