Hello,
I would like to draw a histogram of one interval variable in SAS that also would present a mean of another variable in the bin of the histogram. I'm attaching a pdf to give you an idea what I would like to get.
Regards,
DarekB
Hello @DarekB and welcome to the SAS Support Communities,
You could create an overlay chart as is described here: https://blogs.sas.com/content/graphicallyspeaking/2018/02/05/dual-response-axis-bar-line-overlay-par...
This blog (Graphically Speaking) presents a great variety of plots that can be produced with SAS ODS Graphics.
Thank you very much @FreelanceReinh.
I have one question. Instead of a bar plot with categories I would like to have a histogram of an interval variable drawn by SAS and then a line on the histogram
It seems that more advanced techniques (PROC TEMPLATE) are required to overlay a curve on a histogram:
https://blogs.sas.com/content/iml/2013/04/24/overlay-density-curve-on-a-histogram.html.
I'm not really familiar with PROC TEMPLATE. So, if I were to produce that graph, I would consider creating a bar chart based on the histogram data. For example, if you create the original histogram with PROC UNIVARIATE, you can write the histogram data to a dataset:
A histogram is a bar chart with no spaces between the bars. Add that option to the blog posts and it's essentially the same thing.
@DarekB wrote:
Thank you very much @FreelanceReinh.
I have one question. Instead of a bar plot with categories I would like to have a histogram of an interval variable drawn by SAS and then a line on the histogram
@Reeza My understanding is that to have a histogram you have to calculate bins (categories) based on the interval variable sample distribution. Then you draw a bar plot with calculated bins as categories.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.