Data visualization with SAS programming

sgplot vbar with table

Reply
New Contributor
Posts: 4

sgplot vbar with table

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?  

 

.

SAS Super FREQ
Posts: 3,317

Re: sgplot vbar with table

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

New Contributor
Posts: 4

Re: sgplot vbar with table

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

New Contributor
Posts: 4

Re: sgplot vbar with table

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

Esteemed Advisor
Esteemed Advisor
Posts: 6,996

Re: sgplot vbar with table

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.

New Contributor
Posts: 4

Re: sgplot vbar with table

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

Esteemed Advisor
Esteemed Advisor
Posts: 6,996

Re: sgplot vbar with table

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.

Ask a Question
Discussion stats
  • 6 replies
  • 106 views
  • 0 likes
  • 3 in conversation