Data visualization with SAS programming

Cannot Create a Pie Chart in ODS EXCEL Using PROC GCHART?

Accepted Solution Solved
Reply
Contributor
Posts: 73
Accepted Solution

Cannot Create a Pie Chart in ODS EXCEL Using PROC GCHART?

[ Edited ]

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;

 


Accepted Solutions
Solution
‎08-01-2017 12:09 PM
SAS Super FREQ
Posts: 3,752

Re: Cannot Create a Pie Chart in ODS EXCEL Using PROC GCHART?

Posted in reply to robby_beum

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


All Replies
Solution
‎08-01-2017 12:09 PM
SAS Super FREQ
Posts: 3,752

Re: Cannot Create a Pie Chart in ODS EXCEL Using PROC GCHART?

Posted in reply to robby_beum

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/

 

SAS Super FREQ
Posts: 304

Re: Cannot Create a Pie Chart in ODS EXCEL Using PROC GCHART?

Posted in reply to robby_beum

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

 

Contributor
Posts: 73

Re: Cannot Create a Pie Chart in ODS EXCEL Using PROC GCHART?

Posted in reply to Vince_SAS

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;

SAS Super FREQ
Posts: 304

Re: Cannot Create a Pie Chart in ODS EXCEL Using PROC GCHART?

Posted in reply to robby_beum

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

☑ This topic is solved.

Need further help from the community? Please ask a new question.

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