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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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