Hi All - I've searched these boards and beyond, but cannot find an answer to what seems like a simple query.
I'm relying on 9.4 SAS ODS Graphics documentation, especially:
Why does the GRAPH BORDERCOLOR setting *not* work in this simple example?
*--- Demo Data ;
proc sql;
create table hilo_data
( label char(15) label='Label for High-Low element'
, low num(8) label='Low value for High-Low plot'
, high num(8) label='High value for High-Low plot'
, y_val num(8) label='Y-axis value for High-Low plot'
, lcap char(15) label='Low Cap style for High-Low bars'
, hcap char(15) label='High Cap style for High-Low bars'
)
;
insert into hilo_data
values('One', 1, 5, -1, 'filledArrow', '')
values('Two', 2.5, 7.5, -2, '', '')
values('Tre', 5, 10, -3, '', '')
values('For', 7.5, 12.5, -4, '', '')
values('Fiv', 10, 15, -5, '', 'filledArrow')
;
quit;
*--- MODIFY BORDER COLOR and AXIS COLOR ;
proc template;
define style Modify_Graph_BorderColor;
parent=styles.statistical;
*--- No idea why sgplot IGNORES this element ;
style Graph from Graph /
BorderColor = RED
BorderWidth = 10;
*--- But sgplot DOES x/y axes CYAN ;
style GraphAxisLines from GraphAxisLines /
ContrastColor = CYAN;
end;
run;
*--- SGPLOT ;
ods listing style=Modify_Graph_BorderColor;
ods graphics on /
imagename="test_highlow"
height = 6in width = 4in
reset=index noBorder;
proc sgplot data = hilo_data ;
yaxis display = (nolabel noticks novalues);
highLow
y = y_val
high = high
low = low /
clipCap
type = bar
barwidth = 0.5
lowLabel = label
highCap = hcap
lowCap = lcap;
quit;
That should give you something this - CYAN axes, but NO RED top and right border:
What's the secret to modifying those remaining BorderColors?
The Graph style element applies to SAS/GRAPH. We will remove it from the ODS Graphics documentation. For the overall graph border in ODS Graphics, try setting GraphBorderLines in your style template:
*--- MODIFY BORDER COLOR and AXIS COLOR ;
proc template;
define style Modify_Graph_BorderColor;
parent=styles.statistical;
*--- No idea why sgplot IGNORES this element ;
style GraphBorderLines from GraphBorderLines /
contrastColor = RED
lineThickness = 1px;
style graphWalls from graphWalls /
contrastcolor = PURPLE
lineThickness = 1px;
*--- But sgplot DOES x/y axes CYAN ;
style GraphAxisLines from GraphAxisLines /
ContrastColor = CYAN;
end;
run;
Be sure to specify border=on in your ODS GRAPHICS statement. Be aware that GraphBorderLines affects legend borders as well. We will update the documentation to correct the NOWALL option description as Dan mentioned (thanks, Dan) and to use consistent terminology for the wall outline. Thanks for bringing this to our attention.
Hi GGO,
The top and right borders are part of the graph wall border. In your style template, try setting GraphWalls:
*--- MODIFY BORDER COLOR and AXIS COLOR ;
proc template;
define style Modify_Graph_BorderColor;
parent=styles.statistical;
*--- No idea why sgplot IGNORES this element ;
style graphWalls from graphWalls /
contrastcolor = RED
lineThickness = 1px;
*--- But sgplot DOES x/y axes CYAN ;
style GraphAxisLines from GraphAxisLines /
ContrastColor = CYAN;
end;
run;
For more information, see Axis Line versus Wall Outline in SAS Graph Template Language: User’s Guide.
Thank you, SDengland! That worked. Sort of.
Unfortunately, this terminology all seems muddled to me.
I'm sure it all makes sense, somehow ... but not really.
The magic combination that seems to achieve my objective (control color or graphwall outline, aka data-area border) is:
As mentioned below, this still does not explain why
And no matter what I do, the overall graph border ... red in my template above ... never appears. I've tried:
Hey @GGO , this is just a mistake in the documentation. The NOWALL and NOBORDER options are independent switches so that you have full control over the wall. The NOWALL option removes only the wall fill, while NOBORDER removes the wall border. If you want to get rid of both, specify both options. Here is a little program to demonstrate the point:
proc sgplot data=sashelp.class;
styleattrs backcolor=yellow;
scatter x=weight y=height;
run;
proc sgplot data=sashelp.class nowall;
styleattrs backcolor=yellow;
scatter x=weight y=height;
run;
proc sgplot data=sashelp.class noborder;
styleattrs backcolor=yellow;
scatter x=weight y=height;
run;
proc sgplot data=sashelp.class nowall noborder;
styleattrs backcolor=yellow;
scatter x=weight y=height;
run;
Hope this helps!
Dan
The Graph style element applies to SAS/GRAPH. We will remove it from the ODS Graphics documentation. For the overall graph border in ODS Graphics, try setting GraphBorderLines in your style template:
*--- MODIFY BORDER COLOR and AXIS COLOR ;
proc template;
define style Modify_Graph_BorderColor;
parent=styles.statistical;
*--- No idea why sgplot IGNORES this element ;
style GraphBorderLines from GraphBorderLines /
contrastColor = RED
lineThickness = 1px;
style graphWalls from graphWalls /
contrastcolor = PURPLE
lineThickness = 1px;
*--- But sgplot DOES x/y axes CYAN ;
style GraphAxisLines from GraphAxisLines /
ContrastColor = CYAN;
end;
run;
Be sure to specify border=on in your ODS GRAPHICS statement. Be aware that GraphBorderLines affects legend borders as well. We will update the documentation to correct the NOWALL option description as Dan mentioned (thanks, Dan) and to use consistent terminology for the wall outline. Thanks for bringing this to our attention.
Much appreciated, Dan and SDEngland!
GraphBorderLines ContrastColor (red) does the trick ... although I never would have tried this based on the documentation:
Nothing in that "Portion of Graph Affected" suggests the color of the lines around the overall graph, which is in fact what this element controls:
There are amazing capabilities here, but misleading or wrong documentation renders those capabilities inaccessible and frustrating. I think I was mainly using the appropriate documentation, taking an appropriate approach, but something that should have taken 5min has now taken multiple hours over several days (with my customer/boss waiting anxiously for publishable data displays to their liking ...).
So thank you, both, especially for taking the documentation aspect seriously, as you've indicated, and working to clean this up.
GGO,
I apologize for the problems that the documentation has caused you. We will correct the documentation for the next release of SAS. Thank you very much for your feedback.
Best regards,
Steve
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.