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

Hello everyone, 

I'm using the ODS to create an excel report with alternating colors for rows. 

I'm now trying to get a row to change color based on a returned value within the row. 

if job_rc = 4 then yellow/orange. 

 

Any suggestions to point me in the right direction of adding this functionality? 

 

Regards,

Jonathan

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

ods excel file= "/folders/myfolders/report.xlsx" ;
proc report data=sashelp.class nowd ; 
 column name age;
 define name/ "" display style={cellwidth=2.5in};
 define age/ "" display style={cellwidth=2.5in};
 

  compute age;
  if age le 14 then 
  call define(_row_,"Style","Style={background=yellow}"); 
 endcomp;

run; 

ods excel close;

View solution in original post

4 REPLIES 4
Reeza
Super User

How are you creating your report. What ODS destination are you using?

Please post your code. 

The quick answer is proc report with a compute column - search for papers on the topic. 

Ksharp
Super User

ods excel file= "/folders/myfolders/report.xlsx" ;
proc report data=sashelp.class nowd ; 
 column name age;
 define name/ "" display style={cellwidth=2.5in};
 define age/ "" display style={cellwidth=2.5in};
 

  compute age;
  if age le 14 then 
  call define(_row_,"Style","Style={background=yellow}"); 
 endcomp;

run; 

ods excel close;
jdmarshg
Obsidian | Level 7
Hello yes I was able to find documentation on the topic to get the issue resolved.
BoelterBI
Calcite | Level 5

Hi,

 

ODS excel file= "~/YOURS.xlsx" ;
proc report data=DB.TABLE nowd ;
column name VALUE;
define CITY/ "" display style={cellwidth=3.0in};
define POPULATION/ "" display style={cellwidth=3.0in};

compute CITY;
if age LESS 50000 then
call define(_row_,"Style","Style={background=BLUE}");
end
comp;

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
  • 4 replies
  • 2083 views
  • 1 like
  • 4 in conversation