BookmarkSubscribeRSS Feed
Walternate
Obsidian | Level 7

Hi,

I have a dataset at the person-level (one row=one person). Each person is divided into one of three categories for Var 1, and one of two categories for Var2. Each person also has a value for two continuous variables, Var3, and Var4. What I want is to be able to plot kernel density curves for the sum of Var3 and Var4, one curve for each level of Var1, and one panel for each level of Var2.

In the previous step, I merged two datasets by ID (Var 3 and Var 4 were on different datasets). I also created Var 5, which was the sum of Vars 3 and 4. Then I divided the sum variable into three variables which were populated based on a person's level of Var 1. In other words, if they were level 1 of Var 1, their sum (Var 5) would go under Var5_lvl1, if level 2, Var5_lvl2, and if lvel 3, Var5_lvl3.

The following is the code I'm trying to use to calculate the curves:

proc sgpanel data=data;

panelby Var2;

density Var5_lvl1 /type=kernel ;

density Var5_lvl2/type=kernel;

density Var5_lvl3/type=kernel;

run;

I get an error message that there was a problem computing the data for the histogram or density statement. I'm not really sure why it's having a problem, as the same code worked on a similar dataset I had earlier.

Any help is much appreciated.

1 REPLY 1
Rick_SAS
SAS Super FREQ

Could you provide the exact error message (or the relevant portion of the SAS log)?  To find out if it is PROC SGPLOT or your data, you could try the following (assuming data are sorted by Var2):

proc kde data=data;

   by Var2;

   univar Var5_lvl1 Var5_lvl2 Var5_lvl3 / plots=densityoverlay;

run;

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 Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 819 views
  • 0 likes
  • 2 in conversation