Watch this Ask the Expert session to learn the capabilities of the ODS graphics system for creating graphics used to display oncology data.
You will learn how to:
The questions from the Q&A segment held at the end of the webinar are listed below and the slides from the webinar are attached.
Q&A
Is there a way to convert SG procedure to GTL?
Yes, there is an option on the SGPLOT and SGSCATTER statements called TMPLOUT. Think of it as “template out”. The option takes a filename and dumps a GTL template representation of your procedure request into the file. We do not support that option in SGPANEL because much of the work we do in the procedure would be difficult or impossible to reproduce simply from a GTL template. Even with SGPLOT, you must be aware we can perform some calculations inside the procedure that would require you to use the computed data from the procedure to correctly render the graph with the template. If you run into this case, the output data from the procedure can be captured using the ODS OUTPUT statement. For example:
ods output sgplot=outdata;
proc sgplot data=sashelp.class; vbar age; run;
proc print data=outdata;
run;
However, most of the cases in SGPLOT should work fine with TMPLOUT and it is a terrific way to get started with GTL. So, if you are familiar with SGPLOT, you can code some simple examples and use that as a starting point. You can dump that code as GTL and continue to build on that.
I just updated to 9.4 M8. I miss %SGDESIGN. Is there anything comparable now? It was useful for building the basic GTL code for a plot that I could later refine with features not available in %SGDESIGN.
Unfortunately, no. The technique I mentioned earlier about doing the TMPLOUT (“template out”) for 9.4 M8 is your best option right now. That option can help jump start your GTL creation.
Can we color code the needle based on different final response of each subject?
Yes, this can be done. If I were doing this for a NEEDLE plot, where the COLORRESPONSE option is not currently available, I would create a name for each response range I wanted to represent (e.g. Good, Borderline, Bad) and put them in a discrete attributes map. Then, I would create a small data step that would put these terms in a column based on the response value. Finally, I would use the new column in the GROUP option for the NEEDLE plot and use the discrete attribute map in the standard way.
1) Can we change the axis color without making a style? 2) My workplace has a focus on circular graphs such as a sunburst chart. Is there any word on adding these types of figures in the future?
Regarding the first question about axis color -- unfortunately, no. The axis line attributes must be controlled within the ODS style for now. Regarding the sunburst question -- there are some examples out there where you can use a POLYGON plot to draw those types of displays. Jeff Meyers has worked on macros for building these displays using ODS Graphics (See this post: https://communities.sas.com/t5/SAS-Programming/Sankey-Diagram-using-Jeff-s-macro/m-p/844307) but there is not an explicit sunburst plot type in GTL.
Can you use Unicode characters in the labels and/or for markers?
We support the ODS ESCAPECHAR syntax inside quoted strings (e.g. axis labels, legend labels, etc.), as well as inside the format strings of an associated column format used in the procedure. The default escape sequence is (*ESC*), but you can use the ODS ESCAPECHAR statement to define a single character. The character value can be a Unicode value, or one of our predefined keywords. For example:
ods escapechar ‘~’;
proc sgplot data=sashelp.class;
xaxis label=”Put an ~{unicode alpha} in the label”;
yaxis label=”Put an R~{unicode ‘00b2’x} in the label”;
scatter x=weight y=height; run;
To do this in a marker label, you would need to define a format using PROC FORMAT to use with the marker label column. When you use ODS ESCAPECHAR in PROC FORMAT, you MUST use the (*ESC*) escape sequence instead of your own defined escape char. The reason is this sequence is always valid, and this format could be used outside of your session.
One final thought on this topic: be sure you are using a font that has the character you need, particularly if you are using superscript and subscript values. Certain fonts will have fuller sets of Unicode glyphs than other fonts. If your font does not have the glyph, you will get a box where the character should be.
What does SG stand for?
SG stands for statistical graphics. The whole ODS graphics project came out of our collaborative work with the statistical developers here at SAS. The primary focus of the system was for statistical graphics. All our procedures in SAS/Graph start with “G.” When we created these procedures based on the ODS graphic system, we needed something other than “G” to differentiate them from the older technology. Now we just refer to them as the SG procedures.
Why did you specify the y-axis to increment by a negative value, instead of a min to max by inc, where inc is positive?
Specifying VALUES=(60 to –100 by –20) or VALUES=(-100 to 60 by 20) should give you the same result on the axis.
Can SGPLot be used in combination with annotate?
Absolutely! I would recommend looking at a paper I wrote a while back called, “Now You Can Annotate Your Statistical Graphics Procedure Graphs” (https://support.sas.com/resources/papers/proceedings11/277-2011.pdf). Some of the examples in the paper can now be done using direct procedure syntax (tick value splitting and images for scatter markers), but the principles and techniques described in the paper should give you a good understanding of how annotation works in the SG procedures.
My understanding was that you had to use the default escape character to get the Unicode to render.
Only when you use the Unicode character in a PROC FORMAT string used in ODS Graphics output. Otherwise, you can define an ODS ESCAPECHAR and use it in quoted strings in the procedure syntax and in TITLE/FOOTNOTE statements.
Could you use an attrmap to dictate the colors / labels?
I am not sure about the question being asked. The discrete attributes map can be used to control color, but not the content of labels. However, if you are asking about controlling the color of data labels, the attribute map can be used to control label colors in plot types that bind label color to the GROUP role.
Do you have suggestions for books about GTL for clinical trials? Like a carpenter's book?
I would recommend, “Clinical Graphs using SAS”, by Sanjay Matange (https://www.amazon.com/Clinical-Graphs-Using-Sanjay-Matange/dp/1629597015)
How do you use SAS on Mac?
SAS has not released a version of SAS specifically for the Mac in many years. However, there are options. You can run SAS Studio using SAS Viya in the cloud, which means you just need a browser on the Mac. You can have SAS installed on a Linux box and run it from your Mac using a terminal or a DMS session using XQuarts. You can also run SAS in a container locally on Mac. Check out this article for some tips on how to set up these usages and more: https://www.linkedin.com/pulse/running-sas-macos-samuel-croker
Does SAS offer a class on ODS Graphics, where one can understand all the options that you explored in SGPlot and Proc Template?
SAS offers a course called, “Data Visualization Using SAS ODS Graphics” (https://learn.sas.com/course/view.php?id=679). Our online documentation is a useful source of information about specific options. I would also recommend the Graphically Speaking blog (https://blogs.sas.com/content/graphicallyspeaking/) and online conference papers for exploring more uses of these options.
For the KM example, can you supply the code for what you output in proc lifetest to use?
Here is an example of a PROC LIFETEST to generate the output data (SurvivalPlotData) to feed into SGPLOT:
proc lifetest data=BMT width=200 ;
time T * Status(0);
survival out=SurvivalPlotData
confband=all bandmin=100 bandmax=600 maxtime=2500
conftype=asinsqrt
plots=( surv(atrisk=0 to 2500 by 250) );
strata Group ;
run;
Is there a reference for what color bands are available to use in SAS?
In regard to ODS Graphics, the COLORBAND option can be used to put color bands on every EVEN or ODD category location. The COLORBANDATTRS option can be used to control the color and transparency of the bands.
Recommended Resources
Create a Combined Graph of Tumor Data
Moving from SAS®9 to SAS® Viya®
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.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
Ready to level-up your skills? Choose your own adventure.
Your Home for Learning SAS
SAS Academic Software
SAS Learning Report Newsletter
SAS Tech Report Newsletter