BookmarkSubscribeRSS Feed
Foody
Fluorite | Level 6

Hello everyone,

 

I did a survey to know what people think about my brochure. And i would like to draw a pie with their % good or bad opinion. the variable i want to draw is " Brochure " coded in 1,2,3,4. I would like to choose the color of the pie :

1 = Very good in Green

2= Good in greenyellow

3= satisfying in red

4= not satisfying in Black

 

SAS put me random colors... is it possible to choose each color for each value of the variable drawn in the pie please ?

 

Thank you, if you find me a solution 🙂

 

title1'Readibility of the brochure';
pattern1  color=green;
pattern2  color=greenyellow;
pattern3  color=red;
pattern4  color=black;

proc format;
   value brochure 1='Very Good'
               	            2='Good'
			    3='Satisfying'
			    4='Not Satisfying';
run;

proc gchart data=conso;
PIE brochure/ value=none
              percent=arrow
              slice=arrow
              noheading 
              plabel=(font='Albany AMT/bold' h=1.3 color=depk);
			  format brochure brochure.;
run;
goptions reset=all;

SAS - i don't want these colors.JPG

 

These are the colors that i would like to have.

this is what i want (Excel).JPG


this is what i want (Excel).JPG
3 REPLIES 3
Reeza
Super User

Try the symbol statement with the colour value. 

DanH_sas
SAS Super FREQ

You can do this with a GTL pie chart and a discrete attrmap. Here is a simple example:

 

proc template;
define statgraph pie;
begingraph;
discreteattrmap name="piecolors";
  value "F" / fillattrs=(color=pink);
  value "M" / fillattrs=(color=light_blue);
enddiscreteattrmap;
discreteattrvar attrvar=sex_mapped var=sex attrmap="piecolors";
layout region;
  piechart category=sex_mapped response=weight / datalabelcontent=(category percent)
           datalabelattrs=(size=20pt);
endlayout;
endgraph;
end;

proc sgrender data=sashelp.class template=pie;
run;
GraphGuy
Meteorite | Level 14

I would recommend pre-summarizing your data, and specifying a few extra options in your gchart (if you want the slices to start at the 12-o'clock position, and be ordered clockwise). Here is a slightly modified version of your code, and the output:

 

data conso;
input brochure val;
datalines;
1 .30
2 .61
3 .09
4 .00
;
run;

 

title1'Readibility of the brochure';

 

pattern1 color=green;
pattern2 color=greenyellow;
pattern3 color=red;
pattern4 color=black;

 

proc format;
value brochure 1='Very Good'
2='Good'
3='Satisfying'
4='Not Satisfying';
run;

 

proc gchart data=conso;
PIE brochure/ discrete
type=sum sumvar=val
clockwise angle=90
value=none percent=arrow slice=arrow noheading
plabel=(font='Albany AMT/bold' h=1.3 color=depk);
format brochure brochure.;
run;

 

pie.png

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!

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.

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
  • 3 replies
  • 3353 views
  • 0 likes
  • 4 in conversation