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
- /
- Plotting a Rate on the Y-Axis

- 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

07-25-2013 04:49 PM

Hello,

I would like to create a plot where I have categories in the x-axis (e.g. race, region, etc.) and the rate of an event (e.g. death,) of a binary response variable on the y-axis.

To me this almost seems like plotting the row percent for the "event occured" column in na Rx2 frequency table.

If anyone can give me some guidance on how to best go about this, I would really appreciate it.

Thanks!

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

07-25-2013 05:27 PM

It partly depends on what version of SAS you have. Depending on your data you may want to add a group variable, but again hard to comment without knowing exactly what your data looks like.

Here's my 9.2 solution that uses proc freq to get my percentages and then uses VBAR.

proc freq data=sashelp.class;

table sex*age/out=summary1 outpct;

run;

data graph_data;

set summary1;

where sex='F';

keep sex age pct_col;

pct_col=pct_col/100;

format pct_col percent8.1;

run;

proc sgplot data=graph_data;

vbar age /stat=sum response=pct_col;

run; quit;

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

07-25-2013 08:56 PM

Thank you so much for your help! I am using SAS 9.3 so I will give that a try and see how it goes.

I basically have a variable age that I have grouped into ranges using a format statement, and I would like to have a plot of age group on the x-axis vs. mortality rate in that group on the y-axis. So my code for producing a frequency table (without output) would look something like:

proc freq data=work.temp;

tables age*dead_yn;

format age age_groups.;

run;

I will give this a try and let you know how it works out!