BookmarkSubscribeRSS Feed
tburus
Obsidian | Level 7

I want to produce side-by-side pie charts filtered by group. I prefer the options available with the STATGRAPH template and SGRender, but can't seem to get the code to work. I have two event types. Below is the code I've attempted. The template doesn't throw an error, but it also doesn't produce the desired results (it gives me two grouped pie charts with 0/1 true/false indicators as labels).

 

Code:

proc template;
define statgraph top5pie_compare;
begingraph / datacolors=(&Dblue &Dgray &Dblack &Dblue2 &Dgray2);
layout gridded / columns=1 rows=2;
	layout lattice / columns=2 rows=1 columngutter=2;
		cell;
			cellheader;
				entry "Competition";
			endcellheader;
			piechart category = interest response = pct / group=eval(event_type=1)
			datalabellocation = inside
			datalabelcontent=(category percent)
			datalabelattrs = (family='Arial/bold' weight=bold size=8pt color=&Dgold.)
			categorydirection = clockwise
			dataskin = crisp
			start = 180 name = 'pie'
			otherslice=true
		  	othersliceopts=(type=percent percent=10 label="Other Categories (<10% of Total)" fillattrs=(color=&Dtan));
		endcell;
		cell;
			cellheader;
				entry "Practice";
			endcellheader;
			piechart category = interest response = pct / group=eval(event_type=2)
			datalabellocation = inside
			datalabelcontent=(category percent)
			datalabelattrs = (family='Arial/bold' weight=bold size=8pt color=&DGold.)
			categorydirection = clockwise
			dataskin = crisp
			start = 180 name = 'pie'
			otherslice=true
		  	othersliceopts=(type=percent percent=10 label="Other Categories (<10% of Total)" fillattrs=(color=&Dtan));
		endcell;
	endlayout;
endlayout;
endgraph;
end;
run;
1 REPLY 1

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
  • 479 views
  • 0 likes
  • 2 in conversation