Data visualization with SAS programming

GBARLINE - align pattern of segmented bar with plot?

Posts: 53

GBARLINE - align pattern of segmented bar with plot?


I'm running SAS 9.03.01M2P081512.

When I subgroup a bar on GBARLINE I can dictate the segment appearance using multiple PATTERN statements.   However, in conjunction with multiple PLOT statements how can I align the pattern of the line with the relevant bar segment so that the legend is applicable to both the bar and the line?   I'm happy to deviate from GBARLINE to achieve the desired results if required.

The example below is amended from 33171 - Use PROC GBARLINE to create subgrouped bars.    I would like the lines (PLOT) for Male and female height to match the legend for the bar.

/* Set the graphics environment */

goptions reset=all cback=white border htitle=12pt htext=10pt; 

axis1 label=('Frequency of Age') minor=none;

axis2 label=('Sum of Height') minor=none; 

symbol1 i=join c=black v=dot h=1.3;

legend1 label=('Gender') value=('Female' 'Male') frame;

pattern1 v=solid c=CXDE7E6F;

pattern2 v=solid c=CX7C95CA;

title1 'Using the SUBGROUP option with PROC GBARLINE';

data work.class_demo;

set sashelp.class;

if sex='M' then height_m=height;

if sex='F' then height_f=height;


/* Create the graph using the SUBGROUP= option */

/* on the BAR statement                        */

proc gbarline data= work.class_demo;

  bar age / subgroup=sex legend=legend1

            discrete raxis=axis1


  plot / sumvar= height_m


plot / sumvar= height_f

raxis=axis2 ;



Posts: 53

Re: GBARLINE - align pattern of segmented bar with plot?

Posted in reply to RB1Kenobi

Using SYMBOL statements seems to work, although this example needs a bit of refinement.

symbol2  c=CXDE7E6F interpol=box co=black;

symbol1  c=CX7C95CA interpol=box co=black  ;

Ask a Question
Discussion stats
  • 1 reply
  • 1 in conversation