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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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