Hello all,
Is there any way other than using PROC GCHART or PROC SGPLOT to create a pie chart in SAS?
I believe I don’t have a license for Gchart as mentioned in the log.
proc gchart data=tmp;
pie antibiotic;
run;
For the second way below the pie statement is highlighted in red that I think it doesn’t support pie statement
proc sgplot data=tmp;
pie slice=antibiotic;
run;
Thanks
When you get an error in your code and it is highlighted in red, CHECK THE LOG. (Maxim 2) If your reading of the log doesn't help, SHOW US the log.
Also, when you get an error in your code, check the documentation! (Maxim 1) Here is the documentation for the PIE statement in PROC SGPIE, does it show the syntax that you typed?
@bhr-q wrote:
I didn't get any error, I meant piechart in my coding is in red not the error
Great, but you have typed something that PROC SGPIE does not expect. You have the wrong syntax. Do yourself a favor and look at the documentation (I gave you the link)
Here is the way to pie chart using proc template and ODS. you can try below code:-
Proc sql;
create table input_for_graph as
select model, make, type
from
sashelp.cars
WHERE make in ('Chevrolet','Audi')
;
run;
Proc Template;
define Statgraph my_pie;
Begingraph;
Layout Region;
Piechart Category= type/
datalabellocation = outside
CATEGORYDIRECTION= clockwise
start= 180 Name= 'pie';
discretelegend 'pie'/
title= 'Cars Pie_Chart';
endlayout;
endgraph;
end;
run;
proc sgrender data= input_for_graph
template= my_pie;
run;
Bala Saladi
It could be your some settings with your editor. I see everything normal in SAS studio. Below is the screen shot for the same
Assuming you're on 9.4M6 or later, there is PROC SGPIE:
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/n11xqf2g2rxnmbn1pgk4rbl5vz80.htm
Not sure whey they made it a PROC, rather than a pie statement in SGPLOT.
Let them eat pie - Graphically Speaking (sas.com)
Extended Pie Chart: Donut of Pie - SAS Support Communities
If needed I can make you a pie chart with DSGI (data step graphics interface). But DSGI is not working on Viya and also in SAS 9.4 DSGI is no longer supported as from M6 or so (M6 = Maintenance level 6).
Also, I invite you to do this Google search:
pie chart site:support.sas.com
Good luck,
Koen
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.