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;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

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
  • 774 views
  • 0 likes
  • 2 in conversation