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
- /
- Base SAS Programming
- /
- plot row pct by variable in a histogram

Topic Options

- 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
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-26-2017 05:00 PM

Is there any way to plot one variable and the row pct for that variable by another (from proq freq) as histogram?

Specifically, I have 2 variables, one is continuous that I am treating categorically (1-20) and the other is a binary 0/1 variable. I want to plot the first variable on the x axis and the row percent for the category 1 as the y axis.

Accepted Solutions

Solution

10-26-2017
06:17 PM

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

Posted in reply to Melk

10-26-2017 06:07 PM

What kind of plot? Scatter, bar, pie, line something else?

It may help to remember that the mean of 0/1 coded variable is the percent of 1 values. So with SGPLOT and Hbar or Vbar you could indicate the binary variable as the response variable and request the Stat=mean.

If you must see % symbols then assign a percent format to the binary variable for the plot. No need to use Proc Freq.

Other plots likely will require you to summarize the data, (hint: Proc means or Summary with your category variable as Class and the binary as a Var variable).

All Replies

Solution

10-26-2017
06:17 PM

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

Posted in reply to Melk

10-26-2017 06:07 PM

What kind of plot? Scatter, bar, pie, line something else?

It may help to remember that the mean of 0/1 coded variable is the percent of 1 values. So with SGPLOT and Hbar or Vbar you could indicate the binary variable as the response variable and request the Stat=mean.

If you must see % symbols then assign a percent format to the binary variable for the plot. No need to use Proc Freq.

Other plots likely will require you to summarize the data, (hint: Proc means or Summary with your category variable as Class and the binary as a Var variable).

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

Posted in reply to ballardw

10-26-2017 06:18 PM

worked beautifully - thank you.