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";
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
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
Wow, just like that. Thanks!
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.
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.
I used _c3_ and it worked (instead of using the var name)
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.