01-05-2012 10:17 AM
This is my first post so I appologize if I make some rookie mistakes like placing the question in a wrong place or something like that.
I have a hopefully simple request, i have made a kernel distribution for a number of years by using proc kde and i wanna have them all in the same graph.
Does anyone know a option which can be used? I've looked through the documenation for proc kde, but for me it doesn't seem like the options is there.
01-06-2012 03:02 PM
Welcome! Thanks for a great question!
It sounds like you have variables such as Y2000-Y2011 which represent different yearly measurements of some quantity. You can use the PLOTS=densityoverlay option to overlay the densities of all of these onto a single plot. Here is an example of overlaying two densities in a SASHELP data set:
/* use KDE to overlay estimates of different variables */
proc kde data=sashelp.cars;
univar mpg_city mpg_highway / plots=densityoverlay;
01-06-2012 05:30 PM
Thank you very much for your reply. I think we are almost there but that I was a bit unclear with my formulation.
Ehm so to elaborate: I have a dataset with one observation per firm (variable: lbnr) per year (variable: year) with a variable for how much they grow in percent (emp_growth) and a variable for how many employees they have in average (emp_avg), so I wanna do the kernel distribution for emp_growth for each value of year in 2007-2009 with emp_avg as weight.
I am no expert in proc kde, but for me to see you code doesn't know the role of the year variable, but i definetely could be just misunderstanding you.
01-06-2012 06:22 PM
Sort by year.Then use YEAR as a BY variable and use the OUT= option to save the kernel densities to an output data set. You can use the SERIES statement in PROC SGPLOT to overlay the curves.
If you don't want them overlaid, but are content with a panel, you can use PROC UNIVARIATE. In this case, use YEAR as a CLASS statement. See this example: http://support.sas.com/documentation/cdl/en/procstat/63963/HTML/default/viewer.htm#procstat_univaria...