04-09-2014 01:21 PM
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;
density Var5_lvl1 /type=kernel ;
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.
04-09-2014 01:46 PM
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;
univar Var5_lvl1 Var5_lvl2 Var5_lvl3 / plots=densityoverlay;