I made a pie chart and I want to move/insert the data label into the legend. I have attached an example below.
I also want to reduce the size of the pie chart but keep everything else (footnotes, legend) the same size.
I have also attached my code below.
data_&cat looks like this
types frequency percentage
A 8 80%
B 2 20%
&cat=types
proc template;
define statgraph types;
begingraph;
entryfootnote "Other: &other";
layout region;
piechart category=&cat response=percentage/
datalabellocation=inside
datalabelcontent=(response)
datalabelattrs = (size=8pt)
otherslice=false
categorydirection=clockwise
start = 180
name = 'types';
discretelegend 'types' / border=false
title= "&cat: " location=inside
across=1 valign=top halign=left;
endlayout;
endgraph;
end;
run;
proc sgrender data=data_&cat template=types;
run;
Please post code in a code box opened with the </> icon that appears above the message window. That way it is much easier to discuss the text and show changes. Copy and paste text from the editor should be at least as quick as attaching a text file.
proc template; define statgraph types; begingraph; entryfootnote "Other: &other"; layout region; piechart category=&cat response=percentage/ datalabellocation=inside datalabelcontent=(response) datalabelattrs = (size=8pt) otherslice=false categorydirection=clockwise start = 180 name = 'types'; discretelegend 'types' / border=false title= "&cat: " location=inside across=1 valign=top halign=left; endlayout; endgraph; end; run; proc sgrender data=data_&cat template=types; run;
Since you are using Macro Variables in the code it really helps to provide examples of those as well especially as we need the actual name of the CATEGORY=&CAT in the data set to match.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
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.