Help using Base SAS procedures

Proc sgpanel

Reply
Frequent Contributor
Posts: 138

Proc sgpanel

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.

SAS Super FREQ
Posts: 3,752

Re: Proc sgpanel

Posted in reply to Walternate

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;

Ask a Question
Discussion stats
  • 1 reply
  • 173 views
  • 0 likes
  • 2 in conversation