- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi All,
I'm trying to run a proc univariate to get a histogram of percentages of cores positive (please see attached for the data in excel format). Included in the dataset are the percentages, with maximum percentage of 100%. However, when I tried to graph the histogram, I get 105%. I tried to modified the bin but that didn't help. Could any of you please kindly help?
This is my code:
Proc univariate data=cores_positive; var percent_pos_core; histogram percent_pos_core/normal endpoints=(5 to 90) HREF=34 HREFLABELS ="34% Reference"; Run;
Running this code, I got the figure below. I would like the 100% to be at 100%, not 105%
Thank you very much!
Tien
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
By default, the bins include the left-hand endpoints
[0, 5), [5, 10), ... [95, 100)
so if there is a 100 value in the data, then the algorithm will add a new interval [100, 105).
To get the bins to include the right-hand endpoint, use the RTINCLUDE option on the HISTOGRAM stmt:
data Have;
do i = 1 to 1000;
x = rand("integer", 1, 100);
output;
end;
run;
proc univariate data=Have;
histogram x / endpoints=(0 to 100 by 5) rtinclude;
run;
If your data ALSO includes the value 0, then using RTINCLUDE will add a bin at (-5, 0], but it looks like this isn't relevant to your data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
By default, the bins include the left-hand endpoints
[0, 5), [5, 10), ... [95, 100)
so if there is a 100 value in the data, then the algorithm will add a new interval [100, 105).
To get the bins to include the right-hand endpoint, use the RTINCLUDE option on the HISTOGRAM stmt:
data Have;
do i = 1 to 1000;
x = rand("integer", 1, 100);
output;
end;
run;
proc univariate data=Have;
histogram x / endpoints=(0 to 100 by 5) rtinclude;
run;
If your data ALSO includes the value 0, then using RTINCLUDE will add a bin at (-5, 0], but it looks like this isn't relevant to your data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very very much Rick! You are the best!
Sincerely,
Tien
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
For more information about setting the bins for histograms (PROC UNIVARIATE and PROC SGPLOT), see "Choosing bins for histograms in SAS."
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Rick for posting more information on proc univariate and proc sgplot!
Tien
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Has this question been resolved? If so, please close the thread and indicate the correct answer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Rick! It's been resolved. I have marked your reply as the solution.
Tien