BookmarkSubscribeRSS Feed
bhr-q
Pyrite | Level 9

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

  

 

9 REPLIES 9
PaigeMiller
Diamond | Level 26

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?

 

 

--
Paige Miller
bhr-q
Pyrite | Level 9
I didn't get any error, I meant piechart in my coding is in red not the error
PaigeMiller
Diamond | Level 26

@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)

--
Paige Miller
Bala_Saladi
Fluorite | Level 6

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_0-1728845695554.png

 

Bala Saladi

bhr-q
Pyrite | Level 9
Thanks so much for your help, I did this way and noticed Piechart under proc template (Piechart Category= type/.....)
is highlighted in red.
whymath
Lapis Lazuli | Level 10
Code in red doesn't always means error code, it could be wrongly colored by editor.
Bala_Saladi
Fluorite | Level 6

It could be your some settings with your editor.  I see everything normal in SAS studio. Below is the screen shot for the same

 

Bala_Saladi_0-1728876606710.png

 

Quentin
Super User

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.

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
sbxkoenk
SAS Super FREQ

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

SAS Innovate 2025: Register Now

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!

What is ANOVA?

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.

Discussion stats
  • 9 replies
  • 1444 views
  • 14 likes
  • 6 in conversation