hi,
i got a table like this one:
Treatment | Infection1 | Infection2 | p_value |
A | 3.45 | 4.64 | 0.683 |
B | 4.32 | 9.17 | 0.04 |
C | 2.99 | 1.04 | 0.02 |
and i would like to apply the backgroundcolor=green for the p_value if infection2 is lower then infection1 AND backgroundcolor=red if infection2 is higher than infection1. do somebody know a simple way to change the cell style based on these two conditions?
kind regards
emin
This would be better for proc report.
and next time , post such questions at ODS and Base Reporting could get a good answer.
data have; input Treatment $ Infection1 Infection2 p_value ; cards; A 3.45 4.64 0.683 B 4.32 9.17 0.04 C 2.99 1.04 0.02 ; run; ods listing close; ods html file='c:\temp\x.html' style=sasweb; proc report data=have nowd; columns Treatment Infection1 Infection2 p_value; define Treatment/display; define Infection1/display; define Infection2/display; compute p_value; if Infection1 gt Infection2 then call define(_col_,'style','style={background=green}'); else call define(_col_,'style','style={background=red}'); endcomp; run; ods html close; ods listing;
XIa Keshan
i forgot to say that i use proc print. but if it is complicated for proc print procedure i can use proc report too.
thanks,
emin
Hi,
There are a few papers on changing cell style using proc report and compute blocks. Here is one for starters:
http://support.sas.com/resources/papers/proceedings09/273-2009.pdf
thanks RW9!
i have to say that all examples which i read until now changes the cell format based on the value of the cell itself, and my problem is that the formatting of the cell (p_value) should be based on two conditions: infection2>infection1 and p_value<0.05. can i implement two conditions in the same time in proc template, in proc report or elsewhere?
Yes, you should be able to do that with if statements in the compute, I am not work to test, but something along the lines of:
compute p_value;
if infectiom2 > infection and p_value < 0.05 then call define('p_value','style','style=[background=green]');
endcomp;
Worst comes to worst, do the logic in a datastep, have a noprint variable with binary 1 or 0 and use that in your if statement.
You can reference specific columns/rows/cells also:
http://www2.sas.com/proceedings/forum2008/224-2008.pdf
Some other papers:
This would be better for proc report.
and next time , post such questions at ODS and Base Reporting could get a good answer.
data have; input Treatment $ Infection1 Infection2 p_value ; cards; A 3.45 4.64 0.683 B 4.32 9.17 0.04 C 2.99 1.04 0.02 ; run; ods listing close; ods html file='c:\temp\x.html' style=sasweb; proc report data=have nowd; columns Treatment Infection1 Infection2 p_value; define Treatment/display; define Infection1/display; define Infection2/display; compute p_value; if Infection1 gt Infection2 then call define(_col_,'style','style={background=green}'); else call define(_col_,'style','style={background=red}'); endcomp; run; ods html close; ods listing;
XIa Keshan
Thank you guys!! Everything works as desired.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.