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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 770 views
  • 0 likes
  • 2 in conversation