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  ;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 1 reply
  • 812 views
  • 0 likes
  • 1 in conversation