BookmarkSubscribeRSS Feed
Soha
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;
run;
pie3d Vehicle / sumvar = National angle=45 fill=solid value=OUTSIDE slice=OUTSIDE percent=inside;
run;
quit;

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 : http://support.sas.com/techsup/technote/ts421.html

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.

Thanks
Sohail Mohammad
5 REPLIES 5
Cynthia_sas
SAS Super FREQ
Hi:
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: http://support.sas.com/rnd/base/ods/odsmarkup/htmlpanel.html

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:
http://www.wuss.org/proceedings09/09WUSSProceedings/papers/dpr/DPR-OConnor.pdf (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 (www.roblink.com/SAS/ 😞
http://www.robslink.com/SAS/democd11/multi_info.htm (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:
http://www.robslink.com/SAS/dashboards/aaaindex.htm

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).

cynthia
Soha
Calcite | Level 5
Cynthia,

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.

Thanks
Sohail Mohammad
Soha
Calcite | Level 5
Hi,

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';
run;
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';
run;

proc greplay igout=gseg nofs;
tc sashelp.templt;
template whole;
treplay 1:1 1:2;
quit;
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.

Thanks
Sohail Mohammad
GraphGuy
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.
Cynthia_sas
SAS Super FREQ
Hi:

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:
http://www.robslink.com/SAS/democd11/multi_info.htm (explicitly shows how to put multiple graphs on a single image) using code this type of code:
[pre]
proc greplay igout=gseg tc=sashelp.templt template=l2r2s nofs;
treplay 1:plot1
2:plot3
3:plot2
4:plot4 ;
run;
quit;
[/pre]

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 www.robslink.com web site is the better example for you to follow. This user group paper also shows how to use GREPLAY and discusses the catalogs:
http://www2.sas.com/proceedings/sugi25/25/iv/25p165.pdf

And, here's the documentation site:
http://support.sas.com/documentation/cdl/en/graphref/63022/HTML/default/viewer.htm#greplay-concepts....

cynthia

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 5 replies
  • 3476 views
  • 0 likes
  • 3 in conversation