BookmarkSubscribeRSS Feed
DarekB
Calcite | Level 5

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

6 REPLIES 6
FreelanceReinh
Jade | Level 19

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.

DarekB
Calcite | Level 5

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

FreelanceReinh
Jade | Level 19

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:

https://communities.sas.com/t5/Statistical-Procedures/Exporting-Histogram-Data-to-Excel/m-p/388279#M....

Reeza
Super User

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


 

DarekB
Calcite | Level 5

@Reezato 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.

Reeza
Super User
No disagreement there. Is the calculating the bins the issue? Although SAS will do that automatically with PROC UNIVARIATE or other procedures, I'm sure you're aware that bin selection can change the graph a lot. Anyways, you do need to precalculate the numbers and then create the graph for a combined bar plot anyways. You could run PROC UNIVARIATE and capture the output and use that as your feeder, but it's still a two step process.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1245 views
  • 0 likes
  • 3 in conversation