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

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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