BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Anita_n
Pyrite | Level 9

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? 

1 ACCEPTED SOLUTION

Accepted Solutions
Oligolas
Barite | Level 11

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;

2021-04-13_10h58_07.png

________________________

- Cheers -

View solution in original post

9 REPLIES 9
Oligolas
Barite | Level 11

Hi,

you could try one of the slice-ordering options

 

ANGLE=degrees

 

ASCENDING

 

CLOCKWISE

 

DESCENDING

 

JSTYLE

 

________________________

- Cheers -

GraphGuy
Meteorite | Level 14

How many slices do you have?

Can  you share your code, and output?

 

Anita_n
Pyrite | Level 9

@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;
GraphGuy
Meteorite | Level 14

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.

 

otherpie.png

Anita_n
Pyrite | Level 9

@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

GraphGuy
Meteorite | Level 14

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? 

Oligolas
Barite | Level 11

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;

2021-04-13_10h58_07.png

________________________

- Cheers -

Anita_n
Pyrite | Level 9

@Oligolas thankyou very much. It worked

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 9 replies
  • 2168 views
  • 0 likes
  • 3 in conversation