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;
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/
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/
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
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;
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
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.