BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
warriortv
Obsidian | Level 7

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%

percent cores positive.GIF

Thank you very much!

Tien

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

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.

 

 

View solution in original post

6 REPLIES 6
Rick_SAS
SAS Super FREQ

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.

 

 

warriortv
Obsidian | Level 7

Thank you very very much Rick! You are the best!

Sincerely,

Tien

Rick_SAS
SAS Super FREQ

For more information about setting the bins for histograms (PROC UNIVARIATE and PROC SGPLOT), see "Choosing bins for histograms in SAS."

warriortv
Obsidian | Level 7

Thank you Rick for posting more information on proc univariate and proc sgplot!

Tien

Rick_SAS
SAS Super FREQ

Has this question been resolved? If so, please close the thread and indicate the correct answer.

warriortv
Obsidian | Level 7

Thanks Rick! It's been resolved. I have marked your reply as the solution.

Tien

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 2480 views
  • 3 likes
  • 2 in conversation