BookmarkSubscribeRSS Feed
sasuser63
Calcite | Level 5

I made a pie chart and I want to move/insert the data label into the legend. I have attached an example below.

 

legend_graph.jpg

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;
1 REPLY 1
ballardw
Super User

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.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1 reply
  • 582 views
  • 1 like
  • 2 in conversation