<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Editing slice labels in a donut chart so that they don't overlap in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Editing-slice-labels-in-a-donut-chart-so-that-they-don-t-overlap/m-p/926563#M24572</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data survey;
input name $ q1 &amp;amp; $100.;
datalines;
John Very positive
Cathy Very positive
Phil Very positive
Jason Very positive
Darryl Very positive
Gary Very positive
Courtney Very positive
Andrea Very positive
Dave Very positive
Andy Very positive
Will Very positive
Zach Very positive
Isla Very positive
Florence Very positive
Henry Very positive
Mo Very positive
Evie Very Positive
Nigel Positive
Linda Positive
Anna Positive
Luke Positive
Arlo Positive
Archie Positive
Wendy Positive
Meghan Positive
Jack Positive
Lucy Positive
Theo Positive
Dylan Positive
Grace Positive
Stella Positive
Eva Positive
Nora Positive
Camilla Positive
Violet Positive
Jude Positive
Harry Positive
Louis Neither positive nor negative
Joe Neither positive nor negative
Leo Neither positive nor negative
Janet Neither positive nor negative
Debbie Neither positive nor negative
Alex Neither positive nor negative
Daniel Neither positive nor negative
Nina Neither positive nor negative
Gabe Neither positive nor negative
Oliver Neither positive nor negative
Anthony Neither positive nor negative
Chris Neither positive nor negative
Evan Neither positive nor negative
Adam Neither positive nor negative
Max Neither positive nor negative
Sophia Negative
Mia Negative
Abigail Negative
Caroline Negative
Shane Negative
Chloe Negative
Clint Negative
Lizzie Negative
Sarah Negative
Nick Negative
Amelia Negative
Ava Negative
Hazel Negative
Ivy Negative
Olive Negative
Rose Negative
George Negative
Arthur Negative
Ben Negative
Finn Negative
Elliot Negative
Sam Negative
Josh Negative
Kai Negative
Jacob Negative
Hugo Negative
Mason Negative
Mike Negative
Liam Negative
Vanessa Very negative
Fred Prefer not to say
;


proc freq data=survey noprint order=freq;
table q1/out=freq1 list;
run;
data freq1;
 set freq1;
 datalabel=catx(' ',q1,cats(put(percent,8.2),'%'));
run;


%macro circular_plot(dataset_in=,id=);
data temp;
 set &amp;amp;dataset_in.;
 id+1;id=1000*&amp;amp;id.+id;
 pi=PERCENT*0.01*2*constant('pi');
 cum_pi+pi;
 lag_cum_pi=lag(cum_pi);
 if _n_=1 then lag_cum_pi=0;
run;
data plot;
 set temp;
 /*for a Polygon*/
 do _pi=lag_cum_pi to cum_pi by 0.001; 
 x=&amp;amp;id.*cos(_pi);y=&amp;amp;id.*sin(_pi);output;
 end;
 x=&amp;amp;id.*cos(_pi);y=&amp;amp;id.*sin(_pi);output;

 do _pi=cum_pi to lag_cum_pi by -0.001; 
 x=%sysevalf(&amp;amp;id.+0.5)*cos(_pi);y=%sysevalf(&amp;amp;id.+0.5)*sin(_pi);output;
 end;
 x=%sysevalf(&amp;amp;id.+0.5)*cos(_pi);y=%sysevalf(&amp;amp;id.+0.5)*sin(_pi);output;

keep x y id ;
run;

%CENTROID (plot, sgplot, id)

data want;
merge plot sgplot(rename=(x=centroid_x y=centroid_y)) temp(keep=id datalabel) ;
by id;
output;
call missing(of _all_);
run;

proc append base=final_want data=want force;run;
%mend;


proc delete data=final_want;run;
%circular_plot(dataset_in=freq1,id=1)

ods graphics/ANTIALIASMAX=1000000 ;
proc sgplot data=final_want aspect=1 noautolegend noborder;
polygon x=x y=y id=id/fill outline  lineattrs=(color=white thickness=2) group=id ;
scatter x=centroid_x y=centroid_y/markerchar=datalabel markercharattrs=(size=10) labelstrip;
xaxis offsetmin=0.1 offsetmax=0.1 display=none  ;
yaxis offsetmin=0.1 offsetmax=0.1 display=none  ;
run;


&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1714532730553.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96079iECFA86655D5EBDFF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1714532730553.png" alt="Ksharp_0-1714532730553.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 01 May 2024 03:05:39 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2024-05-01T03:05:39Z</dc:date>
    <item>
      <title>Editing slice labels in a donut chart so that they don't overlap</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Editing-slice-labels-in-a-donut-chart-so-that-they-don-t-overlap/m-p/926424#M24571</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to visualise some survey data using a donut chart in PROC GCHART. Because some adjacent pie slices are very small, their percentages and labels overlap. See below (chart generated using sample data):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="example chart.PNG" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96034i53F67983F5EE2966/image-size/large?v=v2&amp;amp;px=999" role="button" title="example chart.PNG" alt="example chart.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to display the slice percentage on the same line as the slice label instead of after a line break? If yes, can someone provide me with a snippet of code that achieves this? I don't think it's possible within PROC GCHART, but I've heard PROC TEMPLATE or the graphics editor might help (I'm a novice so I can't figure out either). I'm using SAS 8.3.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Alternative solutions I've considered and discarded:&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;U&gt;Reordering slices so that small segments are not together&lt;/U&gt;: can't do that because of the nature of the data (Likert scale).&lt;/LI&gt;&lt;LI&gt;&lt;U&gt;Experimenting with&amp;nbsp;&lt;/U&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;U&gt;ARROW/INSIDE/NONE/OUTSIDE and ANGLE&lt;/U&gt;: already done, labels still overlap in the original data.&lt;/SPAN&gt;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;&lt;U&gt;Using PROC SGPIE instead&lt;/U&gt;: not available in the version of SAS that my organisation uses.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Here's the sample data I used to generate the chart:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data survey;
input name $ q1 &amp;amp; $100.;
datalines;
John Very positive
Cathy Very positive
Phil Very positive
Jason Very positive
Darryl Very positive
Gary Very positive
Courtney Very positive
Andrea Very positive
Dave Very positive
Andy Very positive
Will Very positive
Zach Very positive
Isla Very positive
Florence Very positive
Henry Very positive
Mo Very positive
Evie Very Positive
Nigel Positive
Linda Positive
Anna Positive
Luke Positive
Arlo Positive
Archie Positive
Wendy Positive
Meghan Positive
Jack Positive
Lucy Positive
Theo Positive
Dylan Positive
Grace Positive
Stella Positive
Eva Positive
Nora Positive
Camilla Positive
Violet Positive
Jude Positive
Harry Positive
Louis Neither positive nor negative
Joe Neither positive nor negative
Leo Neither positive nor negative
Janet Neither positive nor negative
Debbie Neither positive nor negative
Alex Neither positive nor negative
Daniel Neither positive nor negative
Nina Neither positive nor negative
Gabe Neither positive nor negative
Oliver Neither positive nor negative
Anthony Neither positive nor negative
Chris Neither positive nor negative
Evan Neither positive nor negative
Adam Neither positive nor negative
Max Neither positive nor negative
Sophia Negative
Mia Negative
Abigail Negative
Caroline Negative
Shane Negative
Chloe Negative
Clint Negative
Lizzie Negative
Sarah Negative
Nick Negative
Amelia Negative
Ava Negative
Hazel Negative
Ivy Negative
Olive Negative
Rose Negative
George Negative
Arthur Negative
Ben Negative
Finn Negative
Elliot Negative
Sam Negative
Josh Negative
Kai Negative
Jacob Negative
Hugo Negative
Mason Negative
Mike Negative
Liam Negative
Vanessa Very negative
Fred Prefer not to say
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Apr 2024 09:23:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Editing-slice-labels-in-a-donut-chart-so-that-they-don-t-overlap/m-p/926424#M24571</guid>
      <dc:creator>ElGent99</dc:creator>
      <dc:date>2024-04-30T09:23:09Z</dc:date>
    </item>
    <item>
      <title>Re: Editing slice labels in a donut chart so that they don't overlap</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Editing-slice-labels-in-a-donut-chart-so-that-they-don-t-overlap/m-p/926563#M24572</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data survey;
input name $ q1 &amp;amp; $100.;
datalines;
John Very positive
Cathy Very positive
Phil Very positive
Jason Very positive
Darryl Very positive
Gary Very positive
Courtney Very positive
Andrea Very positive
Dave Very positive
Andy Very positive
Will Very positive
Zach Very positive
Isla Very positive
Florence Very positive
Henry Very positive
Mo Very positive
Evie Very Positive
Nigel Positive
Linda Positive
Anna Positive
Luke Positive
Arlo Positive
Archie Positive
Wendy Positive
Meghan Positive
Jack Positive
Lucy Positive
Theo Positive
Dylan Positive
Grace Positive
Stella Positive
Eva Positive
Nora Positive
Camilla Positive
Violet Positive
Jude Positive
Harry Positive
Louis Neither positive nor negative
Joe Neither positive nor negative
Leo Neither positive nor negative
Janet Neither positive nor negative
Debbie Neither positive nor negative
Alex Neither positive nor negative
Daniel Neither positive nor negative
Nina Neither positive nor negative
Gabe Neither positive nor negative
Oliver Neither positive nor negative
Anthony Neither positive nor negative
Chris Neither positive nor negative
Evan Neither positive nor negative
Adam Neither positive nor negative
Max Neither positive nor negative
Sophia Negative
Mia Negative
Abigail Negative
Caroline Negative
Shane Negative
Chloe Negative
Clint Negative
Lizzie Negative
Sarah Negative
Nick Negative
Amelia Negative
Ava Negative
Hazel Negative
Ivy Negative
Olive Negative
Rose Negative
George Negative
Arthur Negative
Ben Negative
Finn Negative
Elliot Negative
Sam Negative
Josh Negative
Kai Negative
Jacob Negative
Hugo Negative
Mason Negative
Mike Negative
Liam Negative
Vanessa Very negative
Fred Prefer not to say
;


proc freq data=survey noprint order=freq;
table q1/out=freq1 list;
run;
data freq1;
 set freq1;
 datalabel=catx(' ',q1,cats(put(percent,8.2),'%'));
run;


%macro circular_plot(dataset_in=,id=);
data temp;
 set &amp;amp;dataset_in.;
 id+1;id=1000*&amp;amp;id.+id;
 pi=PERCENT*0.01*2*constant('pi');
 cum_pi+pi;
 lag_cum_pi=lag(cum_pi);
 if _n_=1 then lag_cum_pi=0;
run;
data plot;
 set temp;
 /*for a Polygon*/
 do _pi=lag_cum_pi to cum_pi by 0.001; 
 x=&amp;amp;id.*cos(_pi);y=&amp;amp;id.*sin(_pi);output;
 end;
 x=&amp;amp;id.*cos(_pi);y=&amp;amp;id.*sin(_pi);output;

 do _pi=cum_pi to lag_cum_pi by -0.001; 
 x=%sysevalf(&amp;amp;id.+0.5)*cos(_pi);y=%sysevalf(&amp;amp;id.+0.5)*sin(_pi);output;
 end;
 x=%sysevalf(&amp;amp;id.+0.5)*cos(_pi);y=%sysevalf(&amp;amp;id.+0.5)*sin(_pi);output;

keep x y id ;
run;

%CENTROID (plot, sgplot, id)

data want;
merge plot sgplot(rename=(x=centroid_x y=centroid_y)) temp(keep=id datalabel) ;
by id;
output;
call missing(of _all_);
run;

proc append base=final_want data=want force;run;
%mend;


proc delete data=final_want;run;
%circular_plot(dataset_in=freq1,id=1)

ods graphics/ANTIALIASMAX=1000000 ;
proc sgplot data=final_want aspect=1 noautolegend noborder;
polygon x=x y=y id=id/fill outline  lineattrs=(color=white thickness=2) group=id ;
scatter x=centroid_x y=centroid_y/markerchar=datalabel markercharattrs=(size=10) labelstrip;
xaxis offsetmin=0.1 offsetmax=0.1 display=none  ;
yaxis offsetmin=0.1 offsetmax=0.1 display=none  ;
run;


&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1714532730553.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96079iECFA86655D5EBDFF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1714532730553.png" alt="Ksharp_0-1714532730553.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2024 03:05:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Editing-slice-labels-in-a-donut-chart-so-that-they-don-t-overlap/m-p/926563#M24572</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-05-01T03:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: Editing slice labels in a donut chart so that they don't overlap</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Editing-slice-labels-in-a-donut-chart-so-that-they-don-t-overlap/m-p/926586#M24573</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13585"&gt;@GraphGuy&lt;/a&gt;&amp;nbsp;maybe knew how to do it with&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;PROC GCHART.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2024 06:47:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Editing-slice-labels-in-a-donut-chart-so-that-they-don-t-overlap/m-p/926586#M24573</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-05-01T06:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: Editing slice labels in a donut chart so that they don't overlap</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Editing-slice-labels-in-a-donut-chart-so-that-they-don-t-overlap/m-p/933321#M24728</link>
      <description>&lt;P&gt;Could you provide the code you used to produce your gchart pie chart?&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jun 2024 14:09:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Editing-slice-labels-in-a-donut-chart-so-that-they-don-t-overlap/m-p/933321#M24728</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2024-06-21T14:09:56Z</dc:date>
    </item>
  </channel>
</rss>

