BookmarkSubscribeRSS Feed
Christobal
Calcite | Level 5

Hello all,

I am trying to create a pie chart. The pie chart contains data of nearly 20 subgroups. As there are some slices of some subgroups very small, the values cannot be read because a value overlays another (pls see attached screenshot).

Is there a way to ensure that one value doesn't overlay another one?

ods listing;

goptions reset=all;

goptions target=WINPRTC device=GIF ;

options orientation=landscape;

ods pdf notoc file="D:\PieChart.pdf";;

options nobyline;

legend1 label=none position=(middle left) offset=(5,) across=1;

*LEGEND1 LABEL = NONE SHAPE = BAR(4 PCT, 2 PCT);

pattern1 v=psolid color='CX999999' repeat=1; /*BLACK*/

pattern2 v=psolid color='CX0000FF' repeat=1; /*BLUE*/

pattern3 v=psolid color='CXE8D898' repeat=1; /*CREAM*/

pattern4 v=psolid color='CXFFAA00' repeat=1; /*GOLD*/

pattern5 v=psolid color='CX00FF00' repeat=1; /*GREEN*/

pattern6 v=psolid color='CX8C887A' repeat=1; /*LIGHTGRAYISHBROWN*/

pattern7 v=psolid color='CX2A8307' repeat=1; /*OLIVE*/

pattern8 v=psolid color='CX700000' repeat=1; /*MAROON*/

pattern9 v=psolid color='CXFF8000' repeat=1; /*ORANGE*/

pattern10 v=psolid color='CX703070' repeat=1; /*PURPLE*/

pattern11 v=psolid color='CXE06090' repeat=1; /*LILAC*/

pattern12 v=psolid color='CXFFFF00' repeat=1; /*YELLOW*/

pattern13 v=psolid color='CXE0A860' repeat=1; /*TAN*/

pattern14 v=psolid color='CXFF0055' repeat=1; /*SALMON*/

pattern15 v=psolid color='CX00FFFF' repeat=1; /*CYAN*/

pattern16 v=psolid color='CX4F4F4F' repeat=1; /*CHARCOAL*/

pattern17 v=psolid color='CX142233' repeat=1; /*DEEPGREENISHBLUE*/

pattern18 v=psolid color='CXFF00FF' repeat=1; /*MAGENTA*/

pattern19 v=psolid color='CX8C8385' repeat=1; /*REDDISHGRAY*/

pattern20 v=psolid color='CXB1E599' repeat=1; /*LIGHTYELLOWGREEN*/

proc gchart data=work.specintpromonatanwgruppe;

by monat;

pie agruppe / sumvar=summevonspecintfaktor

              type=sum discrete

              fill=s

              /*group=monat*/

              noheading

              /*across = 2*/

              clockwise

              value=none

              slice=none

              percent=arrow

              legend=legend1

              other=0;

title2 f='Times New Roman' height=3 pct "Monat: #BYVAL1";

run;

quit;

ods pdf close;

ods listing close;

Thanks in advance for every help/assistance.

Best regards

Christobal


overlay.png
9 REPLIES 9
GraphGuy
Meteorite | Level 14

As a general rule-of-thumb, if a pie has so many slices that it is difficult to fit the slice labels,

that's probably a good indication that a pie chart is not a good choice for visualizing this data.

Christobal
Calcite | Level 5

Hello Robert!

Thanks for your answer. From my point of view a pie chart was the best way to visualise the data.

What kind of chart would you recommend?

Regards

Christobal

Reeza
Super User

Descending bar chart..

https://www.google.com/search?q=descending+bar+chart&hl=en&client=firefox-a&hs=vIW&rls=org.mozilla:e...

Not a huge fan of the 3D but that type of graph would probably work.

Christobal
Calcite | Level 5

Hello Reeza,

yes, descending bar chart seems to be a good one. Thanks for this hint.

Dou you (or anyone else) know if it's possible to give each bar an own pattern? Each bar shows one group ("vbar gruppe"). Now every bar has the same colour although I defined 20 different patterns... If this is possible, is it also possible to match one pattern to one

group (the names of the groups are static and always the same). For example I have a group called "TeilA" and the bar for this group should always use pattern3, so that the colour for this group is always the same...

While searching the web I unfortunately were not able to find any information that might help me 😕

Another "problem" is, that my legend doesn't appear?

This is my current code:

ods listing;

goptions reset=all;

goptions target=WINPRTC device=GIF ;

options orientation=landscape;

ods pdf style=gdis_logo notoc file="D:\TEST.pdf";;

axis1 order=(0 to &maxWertGruppe by 200000)

      color=black    

      label=(a=90 f='Times New Roman' c=maroon 'gemessen')

      value=(f='Times New Roman');

axis3 label=none value=(f='Times New Roman' angle=60);

axis4 value=none label=none;

options nobyline;

legend1 label=none position=(middle left) offset=(5,) across=1;

pattern1 color='CX999999'; /*BLACK*/

pattern2 color='CX0000FF' ; /*BLUE*/

pattern3 color='CXE8D898' ; /*CREAM*/

pattern4 color='CXFFAA00' ; /*GOLD*/

pattern5 color='CX00FF00' ; /*GREEN*/

pattern6 color='CX8C887A' ; /*LIGHTGRAYISHBROWN*/

pattern7 color='CX2A8307' ; /*OLIVE*/

pattern8 color='CX700000' ; /*MAROON*/

pattern9 color='CXFF8000' ; /*ORANGE*/

pattern10 color='CX703070' ; /*PURPLE*/

pattern11 color='CXE06090' ; /*LILAC*/

pattern12 color='CXFFFF00' ; /*YELLOW*/

pattern13 color='CXE0A860' ; /*TAN*/

pattern14 color='CXFF0055' ; /*SALMON*/

pattern15 color='CX00FFFF' ; /*CYAN*/

pattern16 color='CX4F4F4F' ; /*CHARCOAL*/

pattern17 color='CX142233' ; /*DEEPGREENISHBLUE*/

pattern18 color='CXFF00FF' ; /*MAGENTA*/

pattern19 color='CX8C8385' ; /*REDDISHGRAY*/

pattern20 color='CXB1E599' ; /*LIGHTYELLOWGREEN*/

proc gchart data=work.specintpromonatgruppe;;

by monat;

          vbar gruppe/ sumvar=summevonspecint                       

                       discrete

                       descending

                       type=sum

                       outside=sum

                       maxis=axis3

                       raxis=axis1

                       legend=legend1

                      

                       ;

title2 f='Times New Roman' height=3 pct "Monat: #BYVAL1";

run;

quit;

ods pdf close;

ods listing close;

Best regards

Christobal

GraphGuy
Meteorite | Level 14

You could use subgroup={some variable} to color the bars (or bar segments) based on some variable.

You could make each bar a different color by using sugbroup=gruppe ... but I don't think it would be good to have so many colors in a bar chart.  Since each bar already has a label, why would it need a color (and then a color legend)?   (In general, I don't recommend using more than about 5 colors.)

What question are you wanting your bar chart to answer, or provide insight into?

Christobal
Calcite | Level 5

Hello Robert,

thanks for your answer. I asked about the colors, because the bars are sorted descending. If a group changes the place with another group, some colleagues said that it's hard to realise this. I also said, that it's not useful to get a chart that looks like a rainbow.... So I think I will use a bar chart that's not sorted descending, because then each bar has always the same place....

But I will try to experiment a little bit with the different solutions...

LeRoyBessler
Obsidian | Level 7

Christobal,

If you are going to do a horizontal bar chart,

I recommend appending to what would ordinarily be your bar label

any additional information of interest.

Since you originally wanted a pie chart,

presumably you were interested in depicting (if not also displayiing numerically) the percent of whole for each value of gruppe.

When a pie chart becomes impractical,

I like to use horizontal bar chart labels consisting of descriptor - value - percent of whole.

You get EVERYTHING of potential interest, plus the visual comparator of bar length.

See, e.g., Figure 3 in http://support.sas.com/resources/papers/proceedings09/220-2009.pdf

where the example is actually a subsetted ranked (descending) horizontal bar chart,

but it demonstrates maximal communication use of the bar label.

In that example, the inelegant technique of leading fill with dashes

could have been avoided by using JUSTIFY=RIGHT on the MAXIS statement.

For examples where the labels are right-justified, and no leading dashes are used, see

the charts created with

SubsettedRankingHbarChartsToHTML macro

or

SubsettedRankingHbarChartsToDisk macro

in http://www.mwsug.org/proceedings/2012/DV/MWSUG-2012-DV13.pdf

This paper creates bar charts with ODS Graphics,

whereas the earlier paper creates them with SAS/GRAPH.

With all bar-related information of interest imbedded in your bar label,

you need no legend.

With the response values imbedded in your bar label,

you need no response axis clutter.

Your midpoint axis needs only the labels, no tick marks and no axis line.

Christobal
Calcite | Level 5

Hello LeRoy,

thank you for your answer, too.

Your answer and links etc. seem to be very interesting and useful. I will try to adapt this for my "problem". Perhaps I can provide my colleagues another good solution.

LeRoyBessler
Obsidian | Level 7

Hello Christobal,

I realize that by now you are probably no longer concerned about

what is now an Assumed Answered question,

but, in case you ARE interested,

you can find my latest work on horizontal bar charts

"Data Visualization Power Tools:

Expedite the Easy, Implement the Difficult, or Handle Big Data"

at

http://www.pharmasug.org/proceedings/2013/DG/PharmaSUG-2013-DG11.pdf

In particular, see Tool 4 for PowerPoint or Word charts or Tool 5 for web charts.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 9 replies
  • 3553 views
  • 6 likes
  • 4 in conversation