Data visualization with SAS programming

Formatting X and Y axis

Reply
N/A
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.

Thanks!
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.
N/A
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 http://support.sas.com/ 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 site:sas.com
SAS Super FREQ
Posts: 8,719

Re: Formatting X and Y axis

Hi:
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:
http://support.sas.com/documentation/cdl/en/grstatug/62464/HTML/default/n1f71f6e9v037an1jy274v66z4r1...
http://support.sas.com/documentation/cdl/en/grstatug/62464/HTML/default/p1b7qx0s2cynrgn1fy2ugk5rz2ek...
http://support.sas.com/documentation/cdl/en/grstatug/62464/HTML/default/p1wp0lm93sf0kan1266430ixhbu1...

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:
http://support.sas.com/documentation/cdl/en/grstatug/62464/HTML/default/p18c2hn0ybnntyn1t6aitke3f0l6...

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.

cynthia
[pre]
ods path work.tmp(update)
sasuser.templat(update)
sashelp.tmplmst(read);

proc template;
define style styles.thick;
parent=styles.statistical;
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")
color=blue;

end;
run;

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

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);
run;
ods _all_ close;
[/pre]
New Contributor
Posts: 4

Re: Formatting X and Y axis

Hi

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

proc template;
define style MyStyleDefault;
parent=Styles.statistical;
style GraphLabelText from GraphLabelText / fontsize = 10px;
style GraphValueText from GraphValueText / fontsize = 8px;
end;
run;


ods html style = MyStyleDefault;

Many thanks,

Kriss
Ask a Question
Discussion stats
  • 5 replies
  • 233 views
  • 0 likes
  • 5 in conversation