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-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 2283 views
  • 0 likes
  • 3 in conversation