BookmarkSubscribeRSS Feed
CP2
Pyrite | Level 9 CP2
Pyrite | Level 9

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;

1 REPLY 1
ballardw
Super User

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 2012 views
  • 3 likes
  • 2 in conversation