Hi all,
I have the following training data:
data test;
infile datalines dlm="," dsd;
input severity @@;
datalines;
0,0,0,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,3,3,3,3,4,4,5,5,5,5,6,7,9,10,11
;
run;
How to built a distribution histogram with visualisation of Median and percentiles using proc univariate.
Thank you!
Your histogram is already displaying zero values. The first bin displays the counts of all values in the half-open interval [0, 2).
That fact might be clearer if you use the ENDPOINTS option to display the endpoints of the bins instead of the midpoints:
histogram severity / href=(2.0 1.0 7.0) endpoints;
You can also change the default bin widths and locations, if necessary.
If it has to be done in PROC UNIVARIATE, I think you can't do that. If you want to do this in PROC UNIVARIATE followed by PROC SGPLOT, then it's pretty simple.
How would you want the graph to look? AFAIK, that isn't a standard histogram and how you identify the percentiles and median can vary.
You didn't say which percentiles you want, but her is how to do it with the 10th and 90th percentiles:
proc means data=test median p10 p90;
var severity;
run;
proc univariate data=test;
var severity;
histogram severity / href=(2.0 1.0 7.0);
inset P10 median P90 / position=NE;
run;
If you prefer the 5th and 95th percentiles, use P5 and P95 in the program.
Thank you, Rick. I have added the "normal" option to see the normal plot approximation(sorry for "my terminology"). I have just one question: how to output "zero" values on the histogram as well
Your histogram is already displaying zero values. The first bin displays the counts of all values in the half-open interval [0, 2).
That fact might be clearer if you use the ENDPOINTS option to display the endpoints of the bins instead of the midpoints:
histogram severity / href=(2.0 1.0 7.0) endpoints;
You can also change the default bin widths and locations, if necessary.
The last line in my previous message links to an article that explains everything.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.