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

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";

1 ACCEPTED SOLUTION

Accepted Solutions
Tim_SAS
Barite | Level 11

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

5 REPLIES 5
Tim_SAS
Barite | Level 11

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...

 

GreggB
Pyrite | Level 9

Wow, just like that.  Thanks!

GreggB
Pyrite | Level 9

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.

 

Tim_SAS
Barite | Level 11

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.

GreggB
Pyrite | Level 9

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

SAS Innovate 2025: Register Now

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!

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
  • 5 replies
  • 6810 views
  • 2 likes
  • 2 in conversation