Hello ,
Is there any way to roundup the percentage values in a pie chart. I don't want any decimal points to be displayed. Also I want the title bold and will like to display all slices even those below 0%. I dont want them to be labelled other.
I used other =0 but still have not the appropriate results. I will appreciate any help. Thanks
You should be able to apply a format directly to it, for example:
proc format is not changing the decimal point a similar chart of what I have. I do not want any decimals
goptions border htitle=12pt htext=10pt;
pattern1 color=red;
pattern2 color=green;
pattern3 color=orange;
pattern4 color=purple;
proc format;
percent pctfmt (round) 0-high='000%';
run;
/* Define a legend */
legend1 label=("my pie")
position=(bottom )
offset=(4,)
across=1
value=(color=black)
shape=bar(4,1.5);
proc gchart data=pie;
title "my pie chart";
pie cars /sumvar= percent
clockwise value=none
legend=legend1
percent=inside
radius=25
noheading;
format percent pctfmt.;
run;
please help I want only intergers without any decimal places
I don't think your user-defined-format is running correctly.
proc format;
percent pctfmt (round) 0-high='000%';
run;
When I try to run it, I get the following error:
237 proc format;
238 percent pctfmt (round) 0-high='000%';
-------
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
NOTE: The previous statement has been deleted.
239 run;
If you were letting Gchart calculate the percent values, I don't think you can control the format (number of decimal places).
But since it appears you're pre-calculating the values of the percent variable, you should be able to control the number of decimal places with a format statement. Rather than writing your own user-defined-format, I would recommend just using the sas-supplied percent format.
Here's some code that shows letting Gchart calculate the percent (where you can't control the format), and then pre-calculating the percent value (where you can control it with SAS' percent format):
title "Using automatically-calculated percent";
title2 "(can't control format)";
proc gchart data=shoes_summarized;
pie region / type=sum sumvar=sales percent=outside value=none noheading other=0;
run;
proc sql noprint;
create table shoes_summarized as
select unique region, sum(sales) as sales
from sashelp.shoes
group by region;
create table shoes_summarized as
select unique region, sales, sum(sales) as total_sales
from shoes_summarized;
quit; run;
data shoes_summarized; set shoes_summarized;
percent=sales/total_sales;
run;
title "Using manually pre-calculated percent";
title2 "(can control format)";
proc gchart data=shoes_summarized;
format percent percent7.0;
pie region / type=sum sumvar=percent value=outside slice=none noheading other=0;
run;
Okay thanks a lot, I will try your suggetions and leave a feedback.
I probably can't control this because gchart is calculating the percent for me.
Thanks for the idea.
Thanks a lot RobertAllison_S, your suggested method did work. It looks very nice
Dear Robert,
This is a very helpful programme.
Is it possible to do the same with "proc template; define statgraph pie" ?
Many thanks,
Kim
The second approach from @GraphGuy should also work for PIECHART in ODS Graphics. Just put your FORMAT statement with the PROC SGRENDER call.
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.
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.
Ready to level-up your skills? Choose your own adventure.