turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS/GRAPH and ODS Graphics
- /
- How to genarate a stack and cluster bar chart toge...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-02-2017 10:03 AM

Hi,

In SAS 9.4, I can use sgplot to generate either stack or cluster bar chart using vbar and groupdisplay=stack (or cluster).

But I have total 4 variables to display in the chart: region, year, grade, and enrollment. I would like to draw 4 'stack and cluster bars' for 4 values of "Region" in the same chart. Each stack should consist of 3 grades and there will be 2 bars for 2 values of "Year" in one cluster. Thus, there should be 4 such clusters for 4 regions.

So, is it possible to genarate a stack and cluster bar chart together using sgplot?

Thnak you.

Accepted Solutions

Solution

03-02-2017
10:27 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to sasuser3

03-02-2017 10:17 AM - edited 03-02-2017 10:29 AM

Scroll down to the 3rd or later example in the article, using the SGPANEL procedure.

Also note, since the date of this article, the AXISTABLE statements havebeen introduced, which is a better way to add table of statistics to a graph. There are many examples of this in the blog. Search for "Axis Table".

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to sasuser3

03-02-2017 10:06 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Sanjay_SAS

03-02-2017 10:14 AM

Thanks for a quick reply. But that example gives only a stack bar chart, not a stack and cluster bar chart. I would like to have at least 2 such stack bars (in a cluster) for each x-category. Fo example, if you have that type of data for another year then we would like to show such stack bars for 2 years for each product in the same chart. How to do it?

Solution

03-02-2017
10:27 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to sasuser3

03-02-2017 10:17 AM - edited 03-02-2017 10:29 AM

Scroll down to the 3rd or later example in the article, using the SGPANEL procedure.

Also note, since the date of this article, the AXISTABLE statements havebeen introduced, which is a better way to add table of statistics to a graph. There are many examples of this in the blog. Search for "Axis Table".

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Sanjay_SAS

03-02-2017 10:30 AM

Thank you very much. I can do that way by removing the gaps between the bars of the products for each year. So they will look more like clustrered for each year. Thanks.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to sasuser3

03-02-2017 10:34 AM

Sure. Set BarWidth=1.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Sanjay_SAS

03-02-2017 10:36 AM

Thank you.