Data visualization with SAS programming

Formatting X and Y axis

Posts: 0

Formatting X and Y axis

Hi, I was trying to change the axises format (namely Thickness and font size) by modifying the default graph template. Can anyone suggest how could I do that? I am using Layout Overlay statements, but not sure which Options (or sub-options) may help.

Super Contributor
Posts: 291

Re: Formatting X and Y axis

if you look up the axis statement in SAS help, you will find a plethora of options to control the appearance of the axes.
Posts: 0

Re: Formatting X and Y axis

While there may have several possibles ways to do it, but I am not sure where to start from.

I was using the Statistical style template and was hoping there is an straightforward way to override the default settings. Any ideas if I can change it by adding an Options functions or if I have to define my own style.

Many thanks!
Super Contributor
Super Contributor
Posts: 3,174

Re: Formatting X and Y axis

Lots of very useful (and free!) information and SAS-hosted DOC on the Support website. Some creative searches either using the website's SEARCH box or Google will yield results for your review.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic / post:

statistical style template
Posts: 8,645

Re: Formatting X and Y axis

You can either change the style settings in the Graph Template Language for using the XAXISOPTS and YAXISOPTS statements (and other statements for changing text attributes, such as in the label and data values). Documentation here:

OR you can alter the style template used for creating your output.

If you have no conflicting settings in your Graph Template, then the style settings in the style template will be used. In order to change your style template, you will need to know which Graph style element to change. Luckily, you can ALSO find this information in the documentation:

and you will see in the above doc that the elements of interest are: GraphAxisLines, GraphValueText, GraphLabelText and GraphDataText (to name just a few)

To get you started with style templates, you might want to search for user group papers on creating style templates. With the recent introduction of ODS GRAPHICS, there are quite a few examples out there of creating custom style templates for use with ODS GRAPHICS.

The example below uses a custom STYLE template with SGPLOT. Every style element is a different color and every font is either a different color, a different font or a different size. So you should be able to figure out which style elements are controlling which pieces of the output -- based on visual clues.

ods path work.tmp(update)

proc template;
define style styles.thick;
class GraphFonts /
'GraphDataFont' = ("Courier New, ",7pt)
'GraphValueFont' = ("Helvetica, ",11pt)
'GraphLabelFont' = ("Helvetica, ",9pt,bold italic)
'GraphTitleFont' = ("Courier New, ",12pt,bold);

class GraphFit /
linethickness = 5px
contrastcolor = pink;

class GraphAxisLines /
linethickness = 6px
contrastcolor = red;

class GraphDataText /
font = GraphFonts("GraphDataFont")
color = purple;

class GraphLabelText /
font = GraphFonts("GraphLabelFont")
color = green;

class GraphValueText /
font = GraphFonts("GraphValueFont")


** Make variable to only label certain cholesterol levels with;
** the gender (instead of labelling every data point).;
data heart;
set sashelp.heart;
if cholesterol le 125 then labl = sex;
else if cholesterol ge 400 then labl=sex;
else labl=' ';

ods listing style=styles.thick;

ods html path='.' (url=none)
file='usethick.html' style=styles.thick;
proc sgplot data=heart;
title '1) Changing Attributes with a Style';
reg y = ageatdeath x=cholesterol/ clm datalabel=labl;
yaxis values=(60 to 95 by 5);
ods _all_ close;
New Contributor
Posts: 4

Re: Formatting X and Y axis


I usually this template to increase the Font Size of the axis titles and values.

proc template;
define style MyStyleDefault;
style GraphLabelText from GraphLabelText / fontsize = 10px;
style GraphValueText from GraphValueText / fontsize = 8px;

ods html style = MyStyleDefault;

Many thanks,

Post a Question
Discussion Stats
  • 5 replies
  • 5 in conversation