BookmarkSubscribeRSS Feed
zuki
Calcite | Level 5

Dear community

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.

Best regards,

zuki

3 REPLIES 3
Rick_SAS
SAS Super FREQ

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;

run;

zuki
Calcite | Level 5

Hi Rick!

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.

Rick_SAS
SAS Super FREQ

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1524 views
  • 0 likes
  • 2 in conversation