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
- /
- sgplot vbar with table

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
- Highlight
- Email to a Friend
- Report Inappropriate Content

4 weeks ago

I am about to make a graph with proc sgplot function and would like to have my table with the freq and percent values from the proc freq table inside the graph. I tried with xaxistable, but that doesn't work. Do any of you have a tip?

.

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

4 weeks ago

Sure. Post some sample data and the code you tried and we can show you how to modify it.

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

4 weeks ago

Hi Rick,

Thank you for your answer. I have attached a test file in excel. The code I have tried is:

**proc** **freq** data=test_EG;

tables antalbarn;

**run**;

**proc** **sgplot** data=test_EG;

vbar antalbarn / stat=percent statlabel datalabel;

format antalbarn barn.;

xaxistable antalbarn;

**run**;

the variable "antalbarn" means how many children do a person have and the values are 0 to 2. And when I do the xaxistable it SUM and when there is 4 persons with two children the xacistable respond with 8 (=4*2) where I would like a table that respond with 4 persons has two children as in the in proc freq table.

I hope that it makes sense?

Thanks.

/Ane

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

4 weeks ago

Or maybe there is a way to show both the percentage and frequency for each bar?

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

4 weeks ago

There are various ways you can do this, depends on what you want the output to look like, destination etc. I find my first port of call on any graph related topic is this excellent blog by Sanjay:

http://blogs.sas.com/content/graphicallyspeaking/

Thousands of examples of all types. Here is one example with values below the graph:

http://blogs.sas.com/content/graphicallyspeaking/2017/04/04/consistent-ordering-graph-components/

Here is one showing titles use:

http://blogs.sas.com/content/graphicallyspeaking/2016/05/23/ctspedia-clinical-graphs-volcano-plot/

You could also plot them if you want them in specific areas etc.

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

4 weeks ago

Or maybe there is a way to show both the percentage and frequency for each bar?

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

4 weeks ago

Yes, as I mention in my post, that blog has examples of all kinds of graphs with code examples. Use the search box on there to find specific things, or just scroll through and see the wonders they have come up with.