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
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.
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.
Thank you very very much Rick! You are the best!
Sincerely,
Tien
For more information about setting the bins for histograms (PROC UNIVARIATE and PROC SGPLOT), see "Choosing bins for histograms in SAS."
Thank you Rick for posting more information on proc univariate and proc sgplot!
Tien
Has this question been resolved? If so, please close the thread and indicate the correct answer.
Thanks Rick! It's been resolved. I have marked your reply as the solution.
Tien
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.