BookmarkSubscribeRSS Feed
Stilllearning
Calcite | Level 5

Hi, I'm a SAS novice but a long timer lurker of the board! I'm trying to create a stacked butterfly plot with 5 bar colors. In order for the data labels to stand out, I'd like to use black text on the VLIGB background and white on the remaining backgrounds. I'd also like to change the font throughout the plot to Arial.  Thank you!

 

Sample Data:

Diagnosis

_2

_1

grade

ALL

70

-70

Group 1

ALL

0

-13

Group 2

AML

2

-2

Group 1

AML

10

-10

Group 2

Breast Cancer

50

-50

Group 1

Breast Cancer

3

-3

Group 2

Breast Cancer

4

-4

Group 3

Breast Cancer

41

-24

Group 4

Breast Cancer

13

-13

Group 5

 

 

Sample Code:

proc sgplot data = work.diagnosis noborder nowall;
styleattrs datacontrastcolors=(black) datacolors=(VLIGB BIGB blue midnightblue  maroon);
format _1 positive.;
hbar aedecod / response = _1 group = grade groupdisplay = stack barwidth=0.7 grouporder=ascending 
seglabel
seglabelfitpolicy = thin
seglabelattrs =(size = 9 weight = bold)
name = "c1";

hbar aedecod / response = _2 group = grade groupdisplay = stack barwidth=0.7 grouporder=ascending
seglabel
seglabelfitpolicy = thin
seglabelattrs = (size = 9 color = white weight = bold);
xaxis grid gridattrs = (pattern = solid) valueattrs = (size=10 weight = bold)
labelattrs = (weight = bold) display=(noticks)
label = "Records (%)" values = (-80 to 80 by 20);
yaxis display = (noline nolabel noticks) discreteorder = data
valueattrs = (weight = bold) label="Patients" labelattrs=(size=10);
keylegend "c1"/ across = 10 noborder title = '' valueattrs=(size=11) sortorder=ascending;
run;

3 REPLIES 3
ballardw
Super User

Example data is best provided as a working data step. That way we don't have to make guesses as to things like variable types. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the </> icon or attached as text to show exactly what you have and that we can test code against.

 

If that isn't possible for you then at least paste the "data" as plain text into a text box opened with the </> icon. That particular "table" appearance is not making a nice set of text to copy/paste into the editor and write code with and I am too lazy to fix whatever not obvious characters make that not nice in the editor manually.

 

Also should provide other info so that we can attempt to run your code. For example you have a custom format named Positive without any definition. Since it is applied to a variable that in your small example data shows apparently negative numeric values the purpose of that format is not at all obvious.

Stilllearning
Calcite | Level 5

Thank you so much for your response! I will try to reformat and update. 

Stilllearning
Calcite | Level 5

Thank you again for you comment! I've created a new topic with the correct format.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 3 replies
  • 581 views
  • 0 likes
  • 2 in conversation