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
- /
- How to include null bins in outhistogram data with...

- 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

01-19-2018 02:10 PM

I am trying to create histograms with certain bins for multiple units. I then need to find the mean and standard errors of all the units at each particular bin. The problem I am having is that my OUTHISTOGRAM statement doesn't include the bins past the last bin I have data in. This is problematic when trying to find accurate means and standard errors as I need the data from ever bin from 0 to 5, even if there is 0 in that bin.

Here is the code I'm using:

proc univariate data=work.serotonin noprint;

histogram Unit1 - Unit25 / midpoints = 0 to 5 by .25

rtinclude

outhistogram = SerotoninHist;

run;

title "5-HT";

Proc means data=work.serotoninhist Mean STDERR;

class _MIDPT_;

var _OBSPCT_ ;

run;

I need the Proc Univariate outhistogram to include all bins from 0 - 5, which then needs to lead to the number of obs column in the Proc means output to read 25 for each bin, allowing accurate means and standard errors.

I'm pretty new to SAS, so any help will be much appreciated!

I'm using SAS University edition.

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

Posted in reply to BrettL

01-19-2018 04:12 PM

BrettL wrote:

... I then need to find the mean and standard errors of all the units at each particular bin.

I need the Proc Univariate outhistogram to include all bins from 0 - 5, which then needs to lead to the number of obs column in the Proc means output to read 25 for each bin, allowing accurate means and standard errors.

I have to say I do not understand exactly what you mean with this. I'm not sure exactly what "each particular bin" means without examples that are more concrete than the code.

Are you saying that you want obs to be 25 when there were not actually 25 observations in a group? Or

If you want to creates summaries by groups that do not exist in your data you'll likely need another approach.

And what would be an accurate mean or standard error?

Perhaps you could provide a small example data set maybe with 20 or so records and fewer midpoints so that you can hand calculate a mean (at least) and demonstrate what you would want for the actual output.

Also many times when I see variables such as your Unit1 to Unit25 (is that the 25 your are referring to?) often part of the solution is to normalize data. What exactly does Unit1 represent that is different than Unit2?

It may be that you should transpose the data so that instead of having 25 variables you have two variables: 1 that represents the unit and the other that has the value.

Then most of the summaries might be doable with BY group processing for the variable containing the unit number.