BookmarkSubscribeRSS Feed
xxformat_com
Barite | Level 11

Hi,

 

The code below adds colors to the borders. In comments, we have the code to remove the borders.

The blue border surrounds the whole graph. What should be updated to have the border only up to the axis?

 

Note that I'm not looking for other methods like "proc template; define style;... class graphwalls..." but really the solution with "proc template; define statgraph....".

 

Regards,

 

proc template;
    define statgraph xxbarchart;
    *begingraph / border=off;
    begingraph / border=on borderattrs=(color=red);
        *layout overlay / walldisplay=(fill);
        layout overlay / border=on borderattrs=(color=blue) walldisplay=(outline);
            barchart x=age / group=sex orient=vertical name='xx'; 
         
            *discretelegend 'xx'/ border=off;
            discretelegend 'xx'/ border=on borderattrs=(color=green);
        endlayout;
    endgraph;
    end;
run;

ods graphics / width=15cm height=10cm;

proc sgrender data=sashelp.class template=xxbarchart;
run;

ods graphics off;

support_border.JPG

 

When borders are removed:

support_noborder.JPG

 

Here is an example of expected border limits created using another syntax:

support_expected.JPG

1 REPLY 1
Jay54
Meteorite | Level 14

Not every aspect of the Graph Style attributes can be modified using the GTL syntax.  As far as I can recall, wall outline attributes and axis line attributes cannot be changed using GTL syntax.  When using only x-y axes, the top and right axis lines are really the wall outline.  One way to change the apparent wall outline or axis line using GTL syntax, you can turn off these display using the syntax options, and then use a DRAWRECTANGLE statement to draw a full rectangle around the wall in WALLPERCENT drawspace.

 

In the code below, if we use W=100 (%), then we get a rectangle width spanning only the data extent from first bar midpoint to last bar midpoint.  So, given we have 6 bars (or, 5 bar spacing), we need to use a W=120% to span the entire space.  This still leaves a few pixels gap, so I used 122%.  You could also use 102% for height (for upper gap), but then use y=51%.

 

proc template;
    define statgraph xxbarchart;
    *begingraph / border=off;
    begingraph / border=on borderattrs=(color=red);
        *layout overlay / walldisplay=(fill);
        layout overlay / border=on borderattrs=(color=blue) walldisplay=none
                         xaxisopts=(display=(ticks tickvalues))
                         yaxisopts=(display=(ticks tickvalues));
            barchart x=age / group=sex orient=vertical name='xx' displaybaseline=auto;
            drawrectangle x=50 y=51 / width=122 height=102 drawspace=datapercent; 
         
            *discretelegend 'xx'/ border=off;
            discretelegend 'xx'/ border=on borderattrs=(color=green);
        endlayout;
    endgraph;
    end;
run;

ods graphics / width=15cm height=10cm;

proc sgrender data=sashelp.class template=xxbarchart;
run;

ods graphics off;

Wall_Outline.png

 

 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 2080 views
  • 2 likes
  • 2 in conversation