BookmarkSubscribeRSS Feed
GiorGirl
Calcite | Level 5

I'm looking to plot two separate variables on the same bar graph. I am currently using proc gbarline to plot one of the variables, but I'd like another to be displayed next to it as another bar (not a line - essentially another "sumvar" statement).  Is this possible, or is there another way/procedure that will perform this?  Thanks!

6 REPLIES 6
GiorGirl
Calcite | Level 5

FYI - The data is complicated enough that I am also plotting by subgroups and it cannot be transposed to create just one variable to graph.

Jay54
Meteorite | Level 14

If you have SAS 9.2 or higher, you can do this using GTL.  Here is an example from a previous post.  Please post your graph and data so I can send you something closer to what you want.

BarLineLegendGTL.png

GraphGuy
Meteorite | Level 14

Gbarline supports subgrouped bars (stacked segments), but not grouped bars (side-by-side).

One possible work-around is to use Gchart to create the bar chart, and then use annotate

to draw the line.  Here's an example:

http://robslink.com/SAS/democd29/barline.htm

http://robslink.com/SAS/democd29/barline_info.htm

GiorGirl
Calcite | Level 5

Thank you for the information, but it's not quite what I'm looking for.  I'm not actually wanting to put a line on the bar graph, I'm wanting to just make a bar graph that looks like the one you just posted (without the line) - but with two different variables.  I do not have a "type" that both the variables I want to plot are under; they are each their own and must be plotted separately.  Because I also need to plot by subgroups, transposing the data to put them under one heading is not possible.  Can I simply combine two different bar graphs?

GraphGuy
Meteorite | Level 14

Hmm ... well, if you don't want a line, then you definitely don't want to be using Proc GBarline Smiley Happy

You can combine 2 bar charts with Proc GReplay ... but I don't think the results would be what you're wanting.

Could you possibly post up some example data?

And, better yet, maybe "draw" a picture of the graph you're wanting (scan in a hand-drawn graph, or use a drawing package, or something) to show us what you're wanting?

Jay54
Meteorite | Level 14

Which release of SAS are you using?  With SAS 9.2, you can easily combine multiple bar charts in one graph using GTL, with or without the line.

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
  • 6 replies
  • 3223 views
  • 0 likes
  • 3 in conversation