Desktop productivity for business analysts and programmers

Assign pie slice colors the same across the same values of the by group variable

Reply
Frequent Contributor
Frequent Contributor
Posts: 133

Assign pie slice colors the same across the same values of the by group variable

I am trying to create a grouped pie chart by another variable. I created the pie and changed the colors so that they match our corporate colors best. The problem is the colors for each slice match the values of the group variable but they change for each by group variable. How can I make sure that a value of the pie slices have the same color across the group AND the By variables?

 

Also, it seems that the only way to order the slices is alphabetically or by value. Is there any way to assign the order to a sort variable or something like that? There are times that I may want certain slices to be adjacent because they share certain characteristics. 

 

If there is not a way to do this in the EG process flow I can edit the code. This is the code that EG created:

 

PROC SORT
DATA=WORK.ptagestart7407(KEEP=ComboGroup Age COUNT Level)
OUT=WORK.SORTTempTableSorted
;
BY truncplot;
RUN;
PATTERN1 COLOR=CX00539B;
PATTERN2 COLOR=CX820053;
PATTERN3 COLOR=CX00746D;
PATTERN4 COLOR=CXFFCE51;
PATTERN5 COLOR=CX78A13F;
PATTERN6 COLOR=CX996633;
PATTERN7 COLOR = _STYLE_;
PATTERN8 COLOR = _STYLE_;
PATTERN9 COLOR = _STYLE_;
PATTERN10 COLOR = _STYLE_;
PATTERN11 COLOR = _STYLE_;
PATTERN12 COLOR = _STYLE_;
Legend1
CFRAME=CXD2D2D2
;
TITLE;
TITLE1 "Pie Chart";
FOOTNOTE;
FOOTNOTE1 "Generated by the SAS System (&_SASSERVERNAME, &SYSSCPL) on %TRIM(%QSYSFUNC(DATE(), NLDATE20.)) at %TRIM(%SYSFUNC(TIME(), TIMEAMPM12.))";
PROC GCHART DATA =WORK.SORTTempTableSorted
;
PIE ComboGroup /
SUMVAR=COUNT
GROUP=Age
TYPE=SUM
LEGEND=LEGEND1
SLICE=NONE
PERCENT=INSIDE
VALUE=OUTSIDE
OTHER=0
OTHERLABEL="Other"
ACROSS =2
COUTLINE=CX9E9E9E
NOHEADING
;
BY Level;
/* -------------------------------------------------------------------
End of task code
------------------------------------------------------------------- */
RUN; QUIT;

Grand Advisor
Posts: 10,196

Re: Assign pie slice colors the same across the same values of the by group variable

If this is important that it may be time to consider changing to Proc SGPLOT. Starting in SAS 9.3 you can create a dataset with characteristics of appearance for variable levels and use that with the various SG procedures to control such things as color, marker, marker size, line type and other graph appearance options.

Ask a Question
Discussion stats
  • 1 reply
  • 227 views
  • 1 like
  • 2 in conversation