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