BookmarkSubscribeRSS Feed
Fisher
Quartz | Level 8
Hi All,

I am not experienced with pie chart. I had a problem to create my desired pie chart.
here is my data:
data temp;
input Role $ Rate;
datalines;
LPN 0.27
RN 0.64
. 0.09
;
run;

after I run following procedure, I got a pie chart without any label for the missing value for variable Role.

proc gchart data=temp;
pie Role /sumvar=rate
other=0
midpoints='' 'LPN' 'RN'
percent=arrow
slice=arrow
noheading;
run;
quit;

However, I like the slice for the missing value labeled as 'Missing'. Anyone can help me with this? I will appreciate it very much.

Thanks

Fisher
6 REPLIES 6
GraphGuy
Meteorite | Level 14
Perhaps something like this?


data temp;
input Role $ Rate;
datalines;
LPN 0.27
RN 0.64
Missing 0.09
;
run;

proc gchart data=temp;
pie Role /sumvar=rate
other=0
midpoints='Missing' 'LPN' 'RN'
percent=arrow
slice=arrow
noheading;
run;
Fisher
Quartz | Level 8
Thanks Robert.
Obviously that works. But I don't want change the dataset by replacing missing character value with some other characters such as 'Missing' as you suggested.
I believe there must be some other way to go.
GraphGuy
Meteorite | Level 14
Ahh! - that's a little more complex!

In that case, you could use a user-defined format, so the ' ' value prints as the word 'Missing' ...


data temp;
input Role $ Rate;
datalines;
LPN 0.27
RN 0.64
. 0.09
;
run;

proc format;
value $piefmt
' ' = "Missing"
;
run;

proc gchart data=temp;
format Role $piefmt.;
pie Role /sumvar=rate
other=0
midpoints='Missing' 'LPN' 'RN'
percent=arrow
slice=arrow
noheading;
run;
proc print data=temp;
format Role $piefmt.;
run;
Fisher
Quartz | Level 8
Thanks Robert. This is definitely a better way to achieve it, I like it.
By the way, there are not any other graph options to handle this case? I believe there should be some.

Anyway, thanks again, you give me a professional solution. 🙂
GraphGuy
Meteorite | Level 14
An axis statement would allow *much* finer control of the tickmark values ... but the axis statement can only be used with bar charts (not pie charts).

Perhaps this is a sneaky/subtle way to nudge users towards using bar charts instead of pie charts! 😉
Bill
Quartz | Level 8
Nudge? We need to bulldoze!

Save the pies for dessert!

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