BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sascom10
Calcite | Level 5

Hello,
Basically I'm trying to color column cell using value of other column.
I would like to have all values of COL2 displayed colored where COL1='A'.
However, with following code only first value of COL2 where COL1='A' is being displayed colored.

Please suggest!!
Thanks!!


data test1;
  input COL1 $1. COL2 $5. NUM1;
datalines;
A rx1 2
A rx2 1
B rx1 1
B rx2 2
B rx2 5
B rx3 3
run;

ods pdf file="C:\test.pdf" notoc /*style=mystyle*/ uniform;

proc report data=test1 nofs nocenter headline headskip split="/" /*spanrows*/;
  column col1 col2 num1;

  define col1 / group;
  define col2 / group;
  define num1 / analysis sum;

  compute col2;   
if col1='A' then
  call define(_col_, "style", "STYLE=[BACKGROUND=cxFFFF82]");
  endcomp;
run;

ods pdf close;

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

You need to "remember" the value of col1.

proc report data=test1 nofs nocenter headline headskip split="/" /*spanrows*/;
  
column col1 col2 num1;
   define col1 / group;
  
define col2 / group;
  
define num1 / analysis sum;
  
compute before col1;
      col1r=col1;
     
endcomp;
  
compute col2;   
     
if col1r='A' then
         call define(_col_,
"style", "STYLE=[BACKGROUND=cxFFFF82]");
      endcomp;
  
run;

View solution in original post

2 REPLIES 2
data_null__
Jade | Level 19

You need to "remember" the value of col1.

proc report data=test1 nofs nocenter headline headskip split="/" /*spanrows*/;
  
column col1 col2 num1;
   define col1 / group;
  
define col2 / group;
  
define num1 / analysis sum;
  
compute before col1;
      col1r=col1;
     
endcomp;
  
compute col2;   
     
if col1r='A' then
         call define(_col_,
"style", "STYLE=[BACKGROUND=cxFFFF82]");
      endcomp;
  
run;
sascom10
Calcite | Level 5

Excellnt, this works!

Thanks!!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 907 views
  • 1 like
  • 2 in conversation