BookmarkSubscribeRSS Feed
xxformat_com
Barite | Level 11

In the presented Grotta barcharts, the same text color is applied to all segments.

Is it possible to apply different text colors to different segments (eg. white for dark backgrounds and black for other backgrounds) with proc sgplot simply or must proc template/sgrender be used?

 

With proc sgplot, I only see the text statement (but needs lots of data preparation for it) and annotations as possible solution. Correct?

 

  • seglabelattrs(color=) does not allow multiple colors
  • textcolor from a dattrmap table is not working with datalabel/seglabel
  • styleattrs statement: does not offer this feature.
  • proc template: class GraphDataText apply the same color to all segements
  • axistable would not be usable to add values in that case

 

 

 

 

1 REPLY 1
Ksharp
Super User

It does not look like so hard I think .Just prepare the data and using TEXT statement.

 

proc freq data=sashelp.heart noprint;
table status*bp_status/out=temp outpct;
run;
data want;
 set temp;
 by status;
 if first.status then cum_pct=0;
 pct=PCT_ROW*0.01;
 cum_pct+pct;
 x=cum_pct-pct/2;
 format cum_pct pct x percent8.2;
run;
proc sgplot data=want;
styleattrs datacontrastcolors=(black white navy);
hbarparm category=status response=pct/group=bp_status nooutline;
text x=x y=status text=pct/strip contributeoffset=none group=bp_status textattrs=(size=14);
run;

Ksharp_0-1721092120018.png

 

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 1 reply
  • 308 views
  • 1 like
  • 2 in conversation