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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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