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;
Moved to graphs forum.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.