BookmarkSubscribeRSS Feed
ff7t
Calcite | Level 5

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?  

 

.

6 REPLIES 6
Rick_SAS
SAS Super FREQ

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

ff7t
Calcite | Level 5

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

ff7t
Calcite | Level 5

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

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

ff7t
Calcite | Level 5

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

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 2291 views
  • 0 likes
  • 3 in conversation