Help using Base SAS procedures

Proc Univariate Histograms...can I look at a subset of the data?

Reply
Occasional Contributor
Posts: 18

Proc Univariate Histograms...can I look at a subset of the data?

Hello all,

I am trying to plot a histogram of some data in proc univariate. The data values range from 1 to 1,500,000, but most of them are less than 100,000. I want to only look at the range from 1 to 100,000 so my graphs are readable.
Using a where statement won't do, because I would like the end bin of the histogram to peak to represent those that have been truncated.
The MIDPOINTS = option doesn't work...I get the following error:

WARNING: The MIDPOINTS= list was extended to accommodate the data.

Any suggestions? Can this automatic "fix" for the MIDPOINTS option be overwritten?

Thanks so much!
Super Contributor
Super Contributor
Posts: 3,174

Re: Proc Univariate Histograms...can I look at a subset of the data?

You might want to share your SAS code. Also, you can list the MIDPOINTS= values to be used, rather than specifying the parameter as a value-range.

Scott Barry
SBBWorks, Inc.

PROC UNIVARIATE - Volume 3, DOC on HISTOGRAM and MIDPOINTS= parameter:
http://support.sas.com/documentation/onlinedoc/91pdf/sasdoc_913/base_proc_8977.pdf
Occasional Contributor
Posts: 18

Re: Proc Univariate Histograms...can I look at a subset of the data?

My code follows:

/* The variable ranges from 1 to 1,592,250, with most values less than 100,000 */
proc univariate noprint data = analysis_AE;
var analysis_var;
histogram analysis_var / midpoints = 0 to 25000 by 5000;
run;

Specifying individual midpoints doesn't work either, I get the same error. However the goal is to write a macro for this so eventually that would not work (different variables input would have different ranges, etc.), but I just want it to work on a hard coded level first.

Thanks a lot for your interest and any further help!
Super Contributor
Super Contributor
Posts: 3,174

Re: Proc Univariate Histograms...can I look at a subset of the data?

Honestly, you may want to share code that gets a "hard" SAS error, where you have coded explicit MIDPOINTS= values showing how you cannot code a low to high set of values, with intermediate midpoint values more frequent at the lower range. The DOC appears to contradict what you indicate is your experience.

Scott Barry
SBBWorks, Inc.
Occasional Contributor
Posts: 18

Re: Proc Univariate Histograms...can I look at a subset of the data?

Nevermind I just realized that I can code records beyond my bounds as equal to the bounds, creating the effect that I want. Any computed stats from univariate won't be correct, but I don't want any here so that's great.

Thanks for trying to help me, sorry to waste your time.
Ask a Question
Discussion stats
  • 4 replies
  • 265 views
  • 0 likes
  • 2 in conversation