BookmarkSubscribeRSS Feed
Petersi
Calcite | Level 5
Is there an option in PROC GPLOT or on the PLOT statement that will produce a table of plotted values below the graph, similar to the 'Add a Data Table' option when creating a chart in Excel?
12 REPLIES 12
Paige
Quartz | Level 8
No such option in PROC GPLOT. However, PROC PRINT will product such a table.
Flip
Fluorite | Level 6
You can build it with annotate.
Petersi
Calcite | Level 5
Thanks. I was actually just starting to put this together with Annotation, but was hoping there would be a simple option that would take care of this automatically.
Paige
Quartz | Level 8
It is hard for me to imagine how ANNOTATE would be easier than PROC PRINT or PROC REPORT.
Flip
Fluorite | Level 6
Just prettier.
And I am an old dog who has been doing it since before ODS was invented.
Petersi
Calcite | Level 5
Yes, I think I would agree with Paige, but I need the table packaged with the graph output in a .ps file. I think I would still need Annotate to attach the PROC REPORT output in there.
Paige
Quartz | Level 8
> Yes, I think I would agree with Paige, but I need the
> table packaged with the graph output in a .ps file.
> I think I would still need Annotate to attach the
> PROC REPORT output in there.

ODS PS does exactly this. You create your graph in PROC GPLOT, you create your table in PROC PRINT or PROC REPORT, and magically, you have one output file containing both your plot and your table.
Flip
Fluorite | Level 6
See. They are taking all the fun out of it.
Cynthia_sas
SAS Super FREQ
Hi:

Since the original question was how to do something that you can do in Excel, I took that same "look/behavior" to be the requirement. When I make a chart in Excel and then insert a data table, the table appears IMMEDIATELY underneath the X axis of the chart, within the Excel "object" that holds the graph. Similar to the Equity Fund Example here:
http://robslink.com/SAS/democd17/funds.htm (which uses SAS, GPLOT and ANNOTATE)

When you use SAS to create images and route the images to ODS, the Images are converted to the "internal" format for PS, PDF and RTF -- So, for those destinations, unless you can edit the file, the image and table -will- stay together -- not because the table is physically inside the graph area, but because the PS file is the container that holds both objects. Images are placed in an external image file (pointed to by <IMG>) for HTML. For LaTeX, the images are put into PS files for inclusion in the LaTeX document.

If you want ONE image with the data table "inside" the boundary of the image/graph area (as shown in the above example), then technically PROC PRINT or PROC REPORT don't fit the requirement because they place the graph in a table that is external to the graph image area.

Even if you make a PS file that now contains the image and the table in a single file, you have to be able to USE or RENDER the PS file if anyone wants to LOOK at the output. So, the PS file would have to be printed, viewed with GhostView, inserted into a LaTeX document (which might need further processing to be rendered and viewable) or distilled into PDF.

Bob Allison's link is an excellent site with lots of good SAS/Graph and some ODS Graphics examples. He uses ANNOTATE extensively and has posted ALL the code that goes with his graph examples.
http://robslink.com/SAS/Home.htm

cynthia
Paige
Quartz | Level 8
> Since the original question was how to do something
> that you can do in Excel, I took that same
> "look/behavior" to be the requirement.

Digressing momentarily, I opine that using SAS/GRAPH to emulate the look and feel of Excel graphics is one of the stupidest and most pointless things people can do. Excel graphics are poorly designed to convey information ... just ask any graphics design expert.
Cynthia_sas
SAS Super FREQ
Hi, Paige:
I am frequently puzzled by the amount of time, money and energy that people spend trying to make SAS/ODS output look like something that they can do in Excel. But I've also learned that sometimes folks just aren't ready to break the umbilical cord to Mother Microsoft.

I took a course from Edward Tufte a few years back and realized that in order to create some of his classic graphs, you would end up using ANNOTATE a lot. Bob Allison's web site shows a lot of graphs that are "Tufte-esque" and he also participates in Dashboard Spy discussions (or at least some of his graph examples have been mentioned on Dashboard Spy).
http://dashboardspy.wordpress.com/2006/06/16/sales-dashboard-screenshot-using-sasgraph-to-track-sale...
http://sas.weblogsinc.com/2006/06/27/tips-sass-allison-guest-stars-on-dashboard-spy/

and, here's a DM artical by Stephen Few about Bob's winning DM Review graph:
http://www.perceptualedge.com/articles/dmreview/intelligent_dashboard.pdf.

cynthia
Cynthia_sas
SAS Super FREQ
Hi:
Annotate would place/position the information in the graphic image area. PRINT/REPORT would position the table outside the graph area -- as a separate, tabular object. If you used the ODS HTMLPANEL destination, you can place the image and the table side by side, or in two rows. But they would still be physically separate, the graphic image would not contain the data table.

There may be an alternative to Annotate, depending on the size of the data table. In SAS 9.2, you could use the SGPLOT procedure, which has an INSET statement. That allows placement, generally, of smaller tables. For example, this PROC SQL step gets the highest HIGH, the maximum CLOSE and the lowest LOW numbers and writes them with an INSET statement:
[pre]
proc sql noprint;
select max(close),
max(high),
min(low) into :maxclose, :maxhigh, :minlow
from sashelp.stocks
where (date >= "01jan2000"d and stock = "IBM");
run;
quit;

%put maxclose=&maxclose maxhigh=&maxhigh minlow=&minlow;

ods listing;
proc sgplot data=sashelp.stocks
(where=(date >= "01jan2000"d and stock = "IBM"));
title "Stock Trend";
series x=date y=close;
series x=date y=low;
series x=date y=high;
inset ("Max Close" = "&maxclose"
"Highest High" = "&maxhigh"
"Lowest Low"=" &minlow")
/ border valuealign=left position=topright
title="Key Numbers"
titleattrs=GraphLabelText;
run;
quit;
[/pre]

In order to use the SG procedures, you must have SAS 9.2. For large data tables, with a lot of columns or many rows, the inset approach would not be effective since the text box is positioned -inside- the plot area.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 12 replies
  • 3585 views
  • 0 likes
  • 4 in conversation