Good Afternoon, I am looking to set the colors of each individual pice slice based on the catagory value (Alignment). Is there a means to do or control this. Below is a example of the code I am utilizing. Thank you.
PROC TEMPLATE;
DEFINE STATGRAPH PIPEPIE;
BEGINGRAPH;
ENTRYTITLE 'Current Pipeline Distribution';
ENTRYFOOTNOTE ' As of ';
layout region;
piechart category=Alignment response=PERCENT1
/ dataskin=crisp datalabellocation=outside;
endlayout;
endgraph;
end;
run;
PROC SGRENDER DATA=WORK.PIPE_PIE1 template=PIPEPIE;
RUN;
You can use a discrete attrmap to do it. Here is a simple example:
proc template;
define statgraph pie;
begingraph;
discreteattrmap name="gender";
value "F" / fillattrs=(color=pink);
value "M" / fillattrs=(color=lightblue);
enddiscreteattrmap;
discreteattrvar attrvar=gender var=sex attrmap="gender";
layout region;
piechart category=gender response=height;
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.class template=pie; run;
The attrmap can also be defined in a data set instead of the template, depending on the SAS version you are using.
Hope this helps!
Dan
You can use a discrete attrmap to do it. Here is a simple example:
proc template;
define statgraph pie;
begingraph;
discreteattrmap name="gender";
value "F" / fillattrs=(color=pink);
value "M" / fillattrs=(color=lightblue);
enddiscreteattrmap;
discreteattrvar attrvar=gender var=sex attrmap="gender";
layout region;
piechart category=gender response=height;
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.class template=pie; run;
The attrmap can also be defined in a data set instead of the template, depending on the SAS version you are using.
Hope this helps!
Dan
That certainly did. Thank you very much. My problem was in the ctagory assignment in the layout region. You example helped me figure that out. Thank you again.
Hi,
I'm new both to SAS and SAS communities. I use SAS 9.4.
I am trying to plot multiple pie charts on one page under each other and I need all pies and legends to be centered. I managed to do that with GCHART using ORIGIN option in legend and RADIUS option in pie statement. Now the distance between one pie and corresponding legend is always the same (independently of the group format - when the image size is sufficient) and all pies are the same size.
Next I needed consistent colors in case one group was missing from data. I searched a lot, but apparently I couldn't find a solution for GCHART. Therefore I used your GTL suggestion and it works well, **bleep**, the graphics even looks better now 🙂
BUT I can't fix the distance between the pie and the legend nor the position and size of the pie. Can anyone help me with any of these approaches? Using barcharts is out of the question and I'm really desperate..
I attached two pdf files with the situation i described and really hope there is someone who can help me.
Thank you in advance.
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.