Hi all,
can anyone help me out with this issue. The labels of my created pie chart overlaps. Is there any way to avoid that in a gchart?
You could try to rearrange the order of your slice in order to avoid the overlapping.
With little amount of slices you can do this manually.
legend1 label=none
shape=bar(4,1.5)
position=(top left)
offset=(5,)
across=4
mode=share;
PROC SQL;
select "'"||strip(var1)||"'" into :vars separated by ' '
from test2
;
quit;
%put &=vars;
proc gchart data=test2 ;
pie var1 / sumvar=var2
other=0
midpoints= 'BBBBBBBBBBBBB' 'GGGGGGGGGGGG' 'IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII' 'CCCCCCCCCCC' 'DDDDDDDDDDDD' 'HHHHHHHHHHHHH' 'AAAAAAA' 'LLLLLLLLLLLLLLLLL' 'FFFFFFFFFFFFFFF' 'EEEEEEEEEEEEE'
angle=90
value= inside
percent=arrow
slice=none
noheading
coutline=black
legend=legend1;
;
run;
quit;
- Cheers -
Hi,
you could try one of the slice-ordering options
ANGLE=degrees |
|
ASCENDING |
|
CLOCKWISE |
|
DESCENDING |
|
JSTYLE |
- Cheers -
How many slices do you have?
Can you share your code, and output?
@GraphGuy : here is the data and code
legend1 label=none shape=bar(4,1.5) position=(top left) offset=(5,) across=4 mode=share; proc gchart data=test2 ; pie var1 / sumvar=var2 noheading coutline=black other=0 value= inside angle=-20 descending percent= arrow jstyle legend=legend1; run; quit;
Instead of other=0 (which shows all the slices, no matter how small they are), I recommend using other=1 so that any slice less than 1% is grouped into an 'other' slice.
It is very difficult to place labels on a lot of very small slices, and also difficult for someone viewing a pie chart to gain much value from seeing a lot of very small slices.
@GraphGuy thanks for that, is it also possible to create two pie charts. For example forcing certain slices( not only those with values =1) in "other slice" and displaying the values of "other slice" in a second pie chart
There's nothing automated to create a 2nd pie based on the values that would go in the 'other' slice. You would have to split your dataset, and run Proc Gchart or SGpie twice.
Perhaps a pie chart isn't best suited for the data you're wanting to visualize?
You could try to rearrange the order of your slice in order to avoid the overlapping.
With little amount of slices you can do this manually.
legend1 label=none
shape=bar(4,1.5)
position=(top left)
offset=(5,)
across=4
mode=share;
PROC SQL;
select "'"||strip(var1)||"'" into :vars separated by ' '
from test2
;
quit;
%put &=vars;
proc gchart data=test2 ;
pie var1 / sumvar=var2
other=0
midpoints= 'BBBBBBBBBBBBB' 'GGGGGGGGGGGG' 'IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII' 'CCCCCCCCCCC' 'DDDDDDDDDDDD' 'HHHHHHHHHHHHH' 'AAAAAAA' 'LLLLLLLLLLLLLLLLL' 'FFFFFFFFFFFFFFF' 'EEEEEEEEEEEEE'
angle=90
value= inside
percent=arrow
slice=none
noheading
coutline=black
legend=legend1;
;
run;
quit;
- Cheers -
@Oligolas thankyou very much. It worked
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.