BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
robby_beum
Quartz | Level 8

I can create a vertical bar chart in ODS EXCEL (.xlsx) using PROC SGPLOT but when I substitute that code and replace it with a PROC GCHART to create a pie chart, it doesn't create a chart and no error messages are created in the .xlsx 

 

Does creating a pie chart in PROC GCHART not work with ODS EXCEL?

 

Generates a bar chart in ODS EXCEL:

proc sgplot data=work.data;

   vbar percentage / group=category;

run;

 

Does not generate a pie chart in ODS EXCEL:

proc gchart data=work.data;

   pie category / sumvar=percentage;

run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

If you want an ODS graphics version of a pie chart, check out the %GTLPieChartMacro by Sanjay Matange

http://blogs.sas.com/content/graphicallyspeaking/2012/08/26/how-about-some-pie/

 

View solution in original post

4 REPLIES 4
Rick_SAS
SAS Super FREQ

If you want an ODS graphics version of a pie chart, check out the %GTLPieChartMacro by Sanjay Matange

http://blogs.sas.com/content/graphicallyspeaking/2012/08/26/how-about-some-pie/

 

Vince_SAS
Rhodochrosite | Level 12

This worked for me using SAS 9.4 M4 on Windows:

 

ods _all_ close;

ods Excel file='C:\temp\temp.xlsx';

goptions device=png;

proc gchart data=sashelp.class;
   pie sex / sumvar=age;
run; quit;

ods Excel close;

 

Vince DelGobbo

SAS R&D

 

robby_beum
Quartz | Level 8

Thank You Vince,

I did a little experiment. Your code worked for me as well and it appears that the "goptions device=png;" is what allowed the pie chart to render. I placed the following in my code and both graphs were created in the .xlsx. I then commented out the "goptions device=png;" and reran and only the bar chart was created.

 

goptions device=png;

 

proc gchart data=sashelp.class;
    pie sex / sumvar=age;
run;

 

proc sgplot data=sashelp.class;
    vbar age / group=sex;
run;

Vince_SAS
Rhodochrosite | Level 12

I have had the best results by explicitly specifying the PNG device when creating graphics for Excel.  You can use the ODS GRAPHICS statement to set the image format for SG* procedures.

 

Vince DelGobbo

SAS R&D

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1519 views
  • 2 likes
  • 3 in conversation