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

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