The SAS Output Delivery System and reporting techniques

PROC REPORT color code a cell based on the value

Accepted Solution Solved
Reply
Super Contributor
Posts: 277
Accepted Solution

PROC REPORT color code a cell based on the value

I want my report to color the cells red in the field named pct_ind5a that are less than 56. My code below colors the entire column. I also get a message that pct_ind5a is uninitialized. Yet, the variable is in the data set and it shows on the report.

 

proc report data=join1a nowd split='*' style(header)={background=cx66cc99 font_size=10pt} style(column)={font_size=10pt}
style(report)={vjust=c just=c cellpadding=0pt}
style(column)={just=center};
column ("" school)
(" " pct_ind5a)
(" " pct_ind5b);
define school/ style=[width=200];
define pct_ind5a/ style=[width=80];
define pct_ind5b/style=[width=80];
compute school; endcomp;
compute pct_ind5a;
if pct_ind5a < 56 then call define (_COL_,'style','style={background=red}');
endcomp;
compute pct_ind5b; endcomp;
title "School Profile Reports 2014-2015";


Accepted Solutions
Solution
‎10-28-2016 01:28 PM
Super Contributor
Posts: 394

Re: PROC REPORT color code a cell based on the value

Because pct_ind5a is a numeric variable, it defaults to being an ANALYSIS variable and has the default statistic SUM. Therefore you must refer to it as pct_ind5a.sum in the COMPUTE block.

 

if pct_ind5a.sum < 56 then call define (_COL_,'style','style={background=red}'); 

http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473627.htm

http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000146851.htm#a00006...

 

View solution in original post


All Replies
Solution
‎10-28-2016 01:28 PM
Super Contributor
Posts: 394

Re: PROC REPORT color code a cell based on the value

Because pct_ind5a is a numeric variable, it defaults to being an ANALYSIS variable and has the default statistic SUM. Therefore you must refer to it as pct_ind5a.sum in the COMPUTE block.

 

if pct_ind5a.sum < 56 then call define (_COL_,'style','style={background=red}'); 

http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473627.htm

http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000146851.htm#a00006...

 

Super Contributor
Posts: 277

Re: PROC REPORT color code a cell based on the value

Wow, just like that.  Thanks!

Super Contributor
Posts: 277

Re: PROC REPORT color code a cell based on the value

I introduced some more vars and got this error:

 

ERROR: The variable type of PCT_IND7AST2.SUM is invalid in this context.
NOTE: The preceding messages refer to the COMPUTE block for ind7aST2.

 

Super Contributor
Posts: 394

Re: PROC REPORT color code a cell based on the value

It's difficult to say without more information about PCT_IND7AST2. What is the DEFINE statement for this variable?

 

My previous advice applied to ANALYSIS vars with the default statistic SUM.

Super Contributor
Posts: 277

Re: PROC REPORT color code a cell based on the value

I used _c3_ and it worked (instead of using the var name)

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 521 views
  • 0 likes
  • 2 in conversation