Hi. When I run the following code...
data pie1;
do i=1 to 1000;
v=5;
output;
end;
v=10;
output;
v=15;
output;
v=20;
output;
run;
ods listing gpath='/home/xxx/AHAGM/images';
ods graphics / imagename="pie1" imagefmt=png;
title "pie1";
proc sgpie data=pie1;
pie v / otherpercent=0;
run;
I get this result. My understanding is that using "otherpercent=0" should cause all slices to appear and be labelled.
That is because percent for 15,20,25 are way too small when 1/1000=0.001 .
But the percent is not small when 1/50=0.02 .
Since PIE graph stands for percent, so you could see the slice is very thin and datalabel of them are overlapped (See my graph).
There are two ways you could try:
1) Using my code and print label "10 1 , 15 1 , 20 1" by sganno dataset.
2)Using your code and print label "5 1000" by sganno dataset.
data pie1;
do i=1 to 1000;
v=5;
output;
end;
v=10;
output;
v=15;
output;
v=20;
output;
run;
data pie2;
set pie1;
if _n_ < 951 then delete;
run;
%sganno
data sganno;
%SGTEXT(
LABEL="5 1000",
DRAWSPACE="GRAPHPERCENT" ,
TEXTCOLOR="black" ,
FILLCOLOR="white",
FILLTRANSPARENCY=0,
WIDTH=8,
X1=83,
Y1=48,
id='pie'
)
run;
proc template;
define statgraph simplepie;
begingraph;
entrytitle "Car Models by Origin";
layout region;
piechart category=v / datalabellocation=callout LABELFITPOLICY=NONE
OTHERSLICE=FALSE CENTERFIRSTSLICE=TRUE OUTLINEATTRS=(thickness=0);
endlayout;
annotate /id='pie';
endgraph;
end;
run;
proc sgrender data=pie2 sganno=sganno
template=simplepie;
run;
I think you need to specify the label with OTHERLABEL
data pie1;
do i=1 to 1000;
v=5;
output;
end;
v=10;
output;
v=15;
output;
v=20;
output;
run;
*ods listing gpath='/home/xxx/AHAGM/images';
*ods graphics / imagename="pie1" imagefmt=png;
*title "pie1";
proc sgpie data=pie1;
pie v / otherpercent=1 otherlabel='Other';
run;
No, what I'm trying to get is a slice for every value of v...so it should be count 1000 for 5, and count 1 for 10, 15, and 20. Instead, I'm only getting a count of 1 for 20.
You could try GTL. It looks like GTL have better control.
data pie1; do i=1 to 1000; v=5; output; end; v=10; output; v=15; output; v=20; output; run; proc template; define statgraph simplepie; begingraph; entrytitle "Car Models by Origin"; layout region; piechart category=v / datalabellocation=outside OTHERSLICE=FALSE LABELFITPOLICY=NONE OUTLINEATTRS=(thickness=0); endlayout; endgraph; end; run; proc sgrender data=pie1 template=simplepie; run;
When I run it I'm still only getting one slice for v=5, size 1,000, and one slice for v=20, size 1. If I dial the count for v=5 back to 50, all of the slices show up. I want them to appear when v=1,000.
data pie1;
do i=1 to 50;
v=5;
output;
end;
v=10;
output;
v=15;
output;
v=20;
output;
run;
ods listing gpath='/home/xxx/AHAGM/images';
ods graphics / imagename="pie1" imagefmt=png;
title "pie1";
proc sgpie data=pie1;
pie v / otherpercent=0;
run;
So part of the problem is that you cannot divide the pie into an infinite number of slices.
I am not sure what the physical limit is but since you are asking for a pie with 1,003 slices we can probably assume it is less than 1000.
That is because percent for 15,20,25 are way too small when 1/1000=0.001 .
But the percent is not small when 1/50=0.02 .
Since PIE graph stands for percent, so you could see the slice is very thin and datalabel of them are overlapped (See my graph).
There are two ways you could try:
1) Using my code and print label "10 1 , 15 1 , 20 1" by sganno dataset.
2)Using your code and print label "5 1000" by sganno dataset.
data pie1;
do i=1 to 1000;
v=5;
output;
end;
v=10;
output;
v=15;
output;
v=20;
output;
run;
data pie2;
set pie1;
if _n_ < 951 then delete;
run;
%sganno
data sganno;
%SGTEXT(
LABEL="5 1000",
DRAWSPACE="GRAPHPERCENT" ,
TEXTCOLOR="black" ,
FILLCOLOR="white",
FILLTRANSPARENCY=0,
WIDTH=8,
X1=83,
Y1=48,
id='pie'
)
run;
proc template;
define statgraph simplepie;
begingraph;
entrytitle "Car Models by Origin";
layout region;
piechart category=v / datalabellocation=callout LABELFITPOLICY=NONE
OTHERSLICE=FALSE CENTERFIRSTSLICE=TRUE OUTLINEATTRS=(thickness=0);
endlayout;
annotate /id='pie';
endgraph;
end;
run;
proc sgrender data=pie2 sganno=sganno
template=simplepie;
run;
Yes, I think that's the only solution. I asked for a clarification from Tech Support, it'll be interesting to see what they say.
Nearly 200 sessions are now available on demand in the Innovate Hub.
Watch Now →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.