Data visualization with SAS programming

Label for a missing value in pie chart

Reply
Contributor
Posts: 70

Label for a missing value in pie chart

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
SAS Employee
Posts: 967

Re: Label for a missing value in pie chart

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;
Contributor
Posts: 70

Re: Label for a missing value in pie chart

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.
SAS Employee
Posts: 967

Re: Label for a missing value in pie chart

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;
Contributor
Posts: 70

Re: Label for a missing value in pie chart

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. Smiley Happy
SAS Employee
Posts: 967

Re: Label for a missing value in pie chart

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! ;-)
Super Contributor
Posts: 291

Re: Label for a missing value in pie chart

Nudge? We need to bulldoze!

Save the pies for dessert!
Ask a Question
Discussion stats
  • 6 replies
  • 437 views
  • 0 likes
  • 3 in conversation