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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 1555 views
  • 0 likes
  • 3 in conversation