BookmarkSubscribeRSS Feed
RB1Kenobi
Quartz | Level 8

Hello

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;

run;

/* 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

width=10;

  plot / sumvar= height_m

raxis=axis2;

plot / sumvar= height_f

raxis=axis2 ;

run;

quit;

1 REPLY 1
RB1Kenobi
Quartz | Level 8

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  ;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1221 views
  • 0 likes
  • 1 in conversation