BookmarkSubscribeRSS Feed
Calcite | Level 5
Hi All,

Can any of you please let me know if there is a way thorugh which we can plot two pie charts side by side in one file.

For ex: If I have to compare the spend across different media vehicles in NY to that of National spend; I can chart spend for NY and National spend one after the other using the following code:

proc gchart data=test;
pie3d Vehicle / sumvar = NewYork angle=45 fill=solid value=OUTSIDE slice=OUTSIDE percent=inside;
pie3d Vehicle / sumvar = National angle=45 fill=solid value=OUTSIDE slice=OUTSIDE percent=inside;

But, as said, this code produces the pie charts one after the other but not side by side. I want to know if we can have 2 pie charts side by side?

I came across a document online which does it for vertical bar charts :

So, can we do the same for pie charts too? If so, can someone please help and let me know how we can do it?

I am using SAS 9.2.

Sohail Mohammad
What is your destination of interest?? For example, do you want a web page (ODS HTML)? Do you want a document that you can open in a word processor (ODS RTF)? Or, do you want a document that you can open with Adobe Acrobat Reader(ODS PDF)??? Or, do you want to create just an external image file???

The technique shown in the Tech Support note -- which uses PROC GREPLAY is just one way of producing 2 outputs side-by-side.

If you want ODS HTML output -- or an HTML file that can be opened in a browser, then either the GREPLAY technique or switching to the ODS HTMLPANEL destination is a possibility. ODS HTMLPANEL info here:

For RTF and/or PDF, the GREPLAY technique is also an option. In addition you could investigate the use of COLUMNS=2, as described in this paper and/or ODS LAYOUT: (COLUMNS= starts on page 6, ODS LAYOUT starts on page 11)

In addition, you will find many examples of using GREPLAY to place multiple graphs side-by-side at this web site ( 😞 (explicitly shows how to put multiple graphs on a single image)

And, almost all of these dashboard examples contain GREPLAY examples along with the ANNOTATE facility:

How you create your output depends on the ODS destination that you will use for the output. Also useful to know is your operating system, your version of SAS, and how you are creating the PIE charts (using SAS Enterprise Guide, using SAS Display Manager Windowing Environment, or via batch processing).

Calcite | Level 5

Thanks for the reply.

My destination of interest is a web page. I am using ODS HTML along with the code that I sent in the previous post.

The tech support note does it for a vertical bar chart using GREPLAY. I think I would want to use GREPLAY itself but would like a pie chart. From the tech support note I could understand that the use of axis options and statement helped in putting the charts one beside the other ( I might be wrong too, correct me if I am wrong). And I think we don't have the axis options with 'pie3d' statement in PROC GCHART. So, is it possible to do the same what is done in the tech support but for pie charts. I am asking this because my situation(data and requirement) in excatly similar to what is being talked in the TS note except that I need a pie chart.

I am creating PIE charts using a stored procedure (the user submits information through the web form and the stored procedure is run), I am using XP and SAS 9.2.

Any help would be greatly appreciated.

Sohail Mohammad
Calcite | Level 5

I am using the following code but I am not getting what I wanted. There is a note in the log which says that the foreground color is same as background color and that part of my graph may not be visible. How can I rectify that?

options dev = activex;
ods listing close;
ods html file = "C:\Inetpub\wwwroot\ASL.NET\AspSampleFiles\Repository\pie_new.html";

proc gchart data = test;
pie3d vehicle / sumvar = NewYork legend = legend1;
/*axis1 origin=(15 pct, 20 pct) label=none;*/
/*axis2 origin=(, 28 pct) length=30 pct label=none;*/
legend1 cshadow=black frame label=none value=(j=l) shape=bar(5,2);
Title1 h=4 pct 'Break Down of Spend by Media Vehciles';
title2 h=2 pct m=(25 pct,+0 pct) 'NewYork';
pie3d vehicle/sumvar = overall nolegend;
/* axis1 origin=(60 pct, 20 pct) label=none;*/
/* axis2 origin=(, 28 pct) length=30 pct label=none;*/
title1 h= 4 pct ' ';
title2 h=2 pct m=(70 pct, +0 pct) 'Overall';

proc greplay igout=gseg nofs;
tc sashelp.templt;
template whole;
treplay 1:1 1:2;
ods html close;
ods listing;

Also, when I see the html file, I see the individual pie charts (New York and Overall) one after the other and then another chart area but dont see the chart ( there is a red cross mark at the top left corner of the chart area with the text "Graphics Replay"). Now, I think it is because of that note in the log but what I actually want to see in the html file is just the output from the GREPLAY proc. I dont want to see the two individual charts one after the other, I just want to see the third chart ( the one which will show the two pie charts side by side). Hope I was able to explain my requirements.

Thanks a lot for your help.

Sohail Mohammad
Meteorite | Level 14
I notice your code specifies device=activex.
You cannot use device=activex with "proc greplay".
I would suggest using the "ods htmlpanel" technique instead.

Also, I would suggest using device=png rather than device=activex (in general).
Activex does not support many of the SAS/Graph features (for example, greplay),
and there are also issues with respect to all users being able to view the output.

There is another way to use GREPLAY without explicitly using the axis-shifting technique shown in the Tech Support note. In this method, you use a SAS/GRAPH template that divides the graph area into sections and then you would replay each PIE into a section.

That is the technique illustrated at this link: (explicitly shows how to put multiple graphs on a single image) using code this type of code:
proc greplay igout=gseg tc=sashelp.templt template=l2r2s nofs;
treplay 1:plot1
4:plot4 ;

where the L2R2S template is dividing a graphic area into 4 rectangles (2 up, 2 down) with a space between each rectangle. This is in contrast to the Tech Support note technique, which uses a template that defines the whole graphic area as one area and then replays the shifted images into the whole template.

The technique shown on the web site is the better example for you to follow. This user group paper also shows how to use GREPLAY and discusses the catalogs:

And, here's the documentation site:




SAS is headed back to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team.

Interested in speaking? Content from our attendees is one of the reasons that makes SAS Innovate such a special event!

Submit your idea!

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.

Get the $99 certification deal.jpg



Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 5 replies
  • 3 in conversation