BookmarkSubscribeRSS Feed

Ask the Expert Webinar: Modernize Your Graphs Using ODS Graphics

Started ‎08-17-2023 by
Modified ‎08-17-2023 by
Views 1,790

 

Modernize Your Graphs Using ODS Graphics Q&A, Slides, and On-Demand Recording

 

Watch this Ask the Expert session to learn about the new methods for controlling colors and symbols and inserting tables into your graphs. 

 

Watch the Webinar

 

You will learn how to:

  • Simplify your code using the SG procedures like SGPLOT and SGPANEL.
  • Control the axis and marker symbols used without needing global statements.
  • Use axis tables and attribute maps to customize your graph output.

 

The questions from the Q&A segment held at the end of the webinar are listed below and the programs and slides from the webinar are attached in a zip file for you to download.

 

Q&A

Is GTL and SGRENDER basically equivalent to PROC GREPLAY?

No, GTL and SGRENDER are not equivalent to PROC GREPLAY. With GREPLAY, you take GRSEG catalog entries from previously run SAS/GRAPH procedure steps and you replay the saved graph into a graph template that specifies the place on the output image where the graph is replayed. A SAS/GRAPH template such a one used with GREPLAY specifies an area defined by X/Y coordinates into which the catalog images are replayed.

The Graph Template Language (GTL) of ODS GRAPHICS is defining the way an image should be drawn, once the template is used with your data. That final image generated by the GTL template and your data will be sent to your specified output destination. There is not an existing image being replayed with GTL and SGRENDER. SGRENDER allows you to link your data and variables to a previously saved GTL template so that the image described by the GTL template is sent to the ODS destination.

  Although both SAS/GRAPH GREPLAY and ODS GRAPHICS GTL use the concept of a “template”, the template for SAS/GRAPH GREPLAY is used in a fundamentally different way than the GTL template.

 

Can you address the issue of how titles have changed from SAS/GRAPH to ODS Graphics?

TITLES and FOOTNOTES work the way they have always worked. The default treatment of SAS TITLE and FOOTNOTE statements if for them to be placed “inside” the boundary of the graph. You’ll see this behavior if you run this code:

** title will be inside the boundary of the graph using GTITLE option;

ods pdf file='c:\temp\grf_title_gtitle' gtitle;

 

goptions border;

proc gchart data=sashelp.class;

  vbar sex;

  title 'PROC GCHART with GTITLE option';

run;

 

proc sgplot data=sashelp.class;

  vbar sex;

  title 'PROC SGPLOT with GTITLE option';

run;

ods pdf close;

  But if you use the NOGTITLE option, then the TITLE is controlled by the ODS DESTINATION style template in use for the output. You’ll see this behavior if you run this code:

** title will be outside the boundary of the graph using NOGTITLE option;

ods pdf file='c:\temp\grf_title_nogtitle' nogtitle;

 

goptions border;

proc gchart data=sashelp.class;

  vbar sex;

  title 'PROC GCHART with NOGTITLE option';

run;

 

proc sgplot data=sashelp.class;

  vbar sex;

  title 'PROC SGPLOT with NOGTITLE option';

run;

ods pdf close;

 

Note that the code used both PROC GCHART and PROC SGPLOT and the TITLE statement output was treated the same way in both result files. There’s also a GFOOTNOTE and NOGFOOTNOTE option for footnotes that works the same way. On the documentation page for TITLE and FOOTNOTE statements, here: https://go.documentation.sas.com/doc/en/vdmmlcdc/8.1/grstatproc/n1ukd9sqgqiwwhn1mrx4c1rbse1j.htm you’ll see a list of the TITLE and FOOTNOTE options that are not supported by the Statistical procedures (primarily because some of the options like MOVE and ROTATE were designed to work with SAS/GRAPH procedures).

 

Which version of SAS is used in the demo? Does SAS 9.4 M7 support this?

Yes, all of the code in the presentation was run in a local installation of SAS using SAS 9.4 M7.

 

Can you show the statements in Proc univariate to add the plots to the report? Are there other statements for different plots?

Please refer to the program entitled demo01_base_stat_ods_graphics.sas to see the PROC UNIVARIATE code that was demonstrated. Here’s the site for the UNIVARIATE documentation https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/procstat/procstat_univariate_syntax01.htm you’ll need to refer to the PLOTS option on the PROC UNIVARIATE statement. 

 

Can you explain the benefits of using SAS VA vs ODS and vice versa? Are there things that one can do which the other cannot?

SAS Visual Analytics and ODS Graphics can’t be compared that way, in my opinion.  About all I can say is that both ODS GRAPHICS and SAS Visual Analytics can create graphical images based on your data. But SAS Visual Analytics along with other visual applications, like SAS Visual Statistics, SAS Model Studio and SAS Visual Data Mining and Machine Learning can do so much more than just send graphic images to an ODS destination.

 

Is there a way to create graphs with a Proc report table adjacent via z/OS (mainframe)?

This sounds like a job for ODS LAYOUT and ODS REGION with PROC REPORT and PROC SGPLOT. You’d probably need to use ODS HTML or ODS PDF to generate your output. Here’s a simple example of using ODS LAYOUT and ODS REGION:

options orientation=landscape topmargin=.25in bottommargin=.25in rightmargin=.25in leftmargin=.25in;

 

ods html path="c:\temp" body="2col.html";

ods pdf file="c:\temp\2col.pdf";

ods layout gridded columns=2;

  

ods region;

proc report data=sashelp.class;

   title "combining a graph and a table on the same page";

run;

 

ods region;

proc sgplot data=sashelp.class;

   title "SASHELP.CLASS VBAR";

   vbar sex;

run;

quit;

 

ods layout end;

ods pdf close;

ods html close;

 

Produces this output in the ODS HTML file:

Cynthia_sas_0-1692296899038.png

 

 

The ODS PDF results are similar, just in a different style. For the specifics of creating ODS HTML or ODS PDF output on z/OS, if this simple example doesn’t work for you, then you’d need to ask for more in-depth help from SAS Tech Support.

 

 

Are you able to change the formatting of the legend and the box around the graph?

Yes, look at the SGPLOT documentation on the LEGEND statement, here: https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/graphref/p0anvu6ux4d0ijn1mt06fn9yl0wx.htm . In addition, here’s a great blog post with examples on controlling the legend: https://blogs.sas.com/content/iml/2018/12/03/tips-customize-legends-proc-sgplot.html .

 

How do you label points in SGSCATTER with data values, such as F for females and M for males?

PROC SGSCATTER was not addressed in this presentation. I showed the SCATTER statement in PROC SGPLOT. However, in the PROC SGSCATTER documentation site, https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/n1je1qlb5bvtypn1rhbeyqw5h9rc.ht... you’ll see that the GROUP= option and the DATALABEL option can both be used with the COMPARE, MATRIX and the PLOT statement of PROC SGSCATTER. They will work in approximately the same way that GROUP= and DATALABEL options work with PROC SGPLOT as shown below:

Cynthia_sas_1-1692296899061.png

 

 

Are the any plans to bring PROC GKPI capabilities into ODS Graphics?

I do not know of plans to implement PROC GKPI in ODS GRAPHICS. That would be a good question to post on the SAS Community Graphics Forum https://communities.sas.com/t5/Graphics-Programming/bd-p/sas_graph  or ask of SAS Tech Support.

 

What is your suggestion to produce a Manhattan plot for GWAS in the current SAS version?

Have a look at this Community Forum posting on a Manhattan plot: https://communities.sas.com/t5/Graphics-Programming/Manhattan-Like-chart-generation/td-p/227997 and for a paper about a Genome Wide Association Studies (GWAS) plot specifically, see this user group paper: https://www.lexjansen.com/sesug/2016/RV-175_Final_PDF.pdf .

 

Where, specifically, can I find documentation for the various options available?

You’ll find the statements and options in the documentation for each of the SG Procedures or in the GTL documentation. This is the starting point I always use: https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/titlepage.htm and then from there, I can go to the individual procedures and statements or go to the GTL doc, as shown below:

Cynthia_sas_2-1692296899147.png

 

 

Can you add y2 in SGPANEL?

Look at this Forum post about a Y2 axis with SGPANEL: https://communities.sas.com/t5/Graphics-Programming/Can-we-get-second-y-axis-using-quot-Proc-SGpanel... . In his response, Sanjay posted a Graph Template example that shows a Y2 axis and there’s a screen shot that illustrates what his code produced.

 

Earlier you showed a slide with the ODS functions by 9.4 maintenance release. Are all the ODS functionalities available in SAS Studio?

I think you’re referring to the What’s New slide that I showed. To see the ODS Graphics capabilities that were introduced in each release, I recommended doing a Google search like this:

site: support.sas.com "What's New in SAS ODS Graphics Procedures 9.4"

That search initially took me to the screen shot I showed as the top hit. Now that search takes me to this documentation page: https://support.sas.com/en/software/ods-graphics-suite-support.html#225d546d-bc17-42af-b5be-4f8e3b89... and then I have to click the link for What’s New in order to find the list of new features by release. The other approach is just to double check the documentation for the feature or option you want to use and look for the version information in the Note or Interaction section of the doc, as shown below for HEATMAP and DROPLINE statements of SGPLOT:

Cynthia_sas_3-1692296899211.png

 

 

Is there a way to create a 100% stacked AREA chart with SGPLOT? I've found 100% stacked bar charts, but not area charts.

I think a stacked band plot might do what you want. Take a look at the example of stacked band plots, as described in this blog posting: https://blogs.sas.com/content/iml/2018/01/31/create-stacked-band-plot-sas.html .

 

With ODS graphics, is it possible to create a standard document pdf with text and Graphs/charts, which you can then schedule to export to a list of users each month?

ODS does not provide a way to do job scheduling, that is more of an operating system feature. Some SAS solutions and applications will do scheduling, but those are not inherent to ODS or ODS GRAPHICS. However, you can create a SAS program that will generate text and graphs. Your SAS program could send emails to a list of users or could export reports, one report for each user. Then, once you have that SAS program, you could schedule that program using your system scheduler.

My guess is that you’ll probably need to use some type of macro variables or macro program to be able to specify parameters so the text and graphs would be generated each month as appropriate. Finally, when you say “export” to a list of users, do you mean you want to email the report to a list of users or that you just want to create files on a shared server for a list of users? Either of these is possible, but as I explained ODS doesn’t provide a way to schedule jobs, emails or exports, so once your program was written, than that SAS program could then be scheduled using your regular system scheduler.

 

Do SG graphics procedures support the generation of plots that can be run as a series (e.g. 1 plot per second) to visiualise change over time. Do you have an example of this.
  The SG Procedures do support BY group processing, so that you could produce a series plot for each value of a BY group variable (or multiple BY group variables). The SGPANEL procedure would also allow you to create paneled graphs or small multiples of graphs so that you would get a separate panel for every PANELBY variable. I don't have any good data or examples that illustrates changes over time, especially with time units as small as seconds. However, this blog https://blogs.sas.com/content/graphicallyspeaking/2013/08/24/series-plot-with-a-twist/ illustrates some examples of plotting comparative series over time (bigger units of time) using stock data. This paper https://support.sas.com/resources/papers/proceedings12/235-2012.pdf has some SGPANEL examples using DOW data, by day (second half of the paper). And then, this paper by Sanjay Matange https://support.sas.com/resources/papers/proceedings16/SAS4321-2016.pdf has some examples of clinical graphs that compare measurements over time.
 
  For more in-depth help with your plot example, you might post your question in the Graphics Forum, here: https://communities.sas.com/t5/Graphics-Programming/bd-p/sas_graph or send your question to support@sas.com for help with your data and ODS GRAPHICS. If you send your question to Tech Support, be sure to include your site license number and an example of the data that you want to plot.

 

 

Recommended Resources

Training Course: Data Visualization Using SAS® ODS Graphics

Graphically Speaking Blog

R&D Graphics Focus Area

Graph Style Tip Sheet

Moving from SAS®9 to SAS® Viya®

Move to Viya Board

Please see additional resources in the attached slide deck.

 

Want more tips? Be sure to subscribe to the Ask the Expert board to receive follow up Q&A, slides and recordings from other SAS Ask the Expert webinars.  

 

Version history
Last update:
‎08-17-2023 05:02 PM
Updated by:

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Article Labels
Article Tags