Overlay Histogram and Regression plot

#1
I'd like to overlay a histogram and plot of regression predictions with confidence bands, such as the figure I've attached (from Rayman MP Lancet. 2012 Mar 31;379(9822):1256-68.). Does anyone know how to make a similar figure in SAS? I've tried proc sgplot and proc sgpanel, but they both give an error indicating that the plot types are not compatible.
 

hlsmith

Not a robit
#2
Hmm, I would be interested in helping you create this. I like trying to get better in SAS. Do you have a dataset to work from? Do you need 3 axes?
 
#4
Thanks for the offer hlsmith. I don't have any data to work with just yet, but I will eventually have some results that I thought would be neat to plot in that way. I think it might require using proc template to position the two separate graphics. I'd be plotting the predicted values and confidence band from logistic regression rather than survival analysis, so I'd like one y axis to correspond to the regression plot and the opposite y axis to correspond to the the histogram (which would represent the sample size), and the x axis would be the predictor of interest. I've attached the full figure since the axes labels got cut off.

PeterFlom: thanks, but that code is for overlaying a density plot onto a histogram, but I would like to overlay a regression plot and a histogram.
 

Dason

Ambassador to the humans
#5
I just want to say that I think this is a bad idea. What do you gain from overlaying the plots here? It just makes it messy and makes it harder to actually understand what the plot is saying.
 

hlsmith

Not a robit
#6
I agree with Dason that it can be difficult to read. If you had just the right variables and better labels it may have a use some where. On Friday I was using I believe proc sgplot (sp?) to plot a splines that looked like everything but without the histogram. If I remember i will post a link to that code next week.