Data visualization with SAS programming

proc univariate - kernel

Reply
Contributor
Posts: 45

proc univariate - kernel

can anyone tell me how i can put 2 variables on the same plot ?

thanks

CL

SAS Super FREQ
Posts: 1,081

Re: proc univariate - kernel

It is easier to help if you provide more information.  If you want to get histograms of two variables, you can do that using SGPLOT procedure with two variables like below.  You can add Normal and Kernel density plots, or customize the plot as you want.

TwoVarHistogram.png

title 'Distribution of Blood Pressure';

proc sgplot data=sashelp.heart;

  histogram systolic / transparency=0.5 binwidth=5;

  histogram diastolic / transparency=0.5 binwidth=5;

  keylegend / location=inside position=topright across=1;

  xaxis display=(nolabel);

run;

Contributor
Posts: 45

Re: proc univariate - kernel

how do i add the kernel plot ?

Super Contributor
Posts: 543

Re: proc univariate - kernel

Something like this:

proc sgplot data=sashelp.heart;

  histogram systolic / transparency=0.5 binwidth=5 ;

  density systolic / type=kernel (c = 0.75);

  histogram diastolic / transparency=0.5 binwidth=5;

  keylegend / location=inside position=topright across=1;

  xaxis display=(nolabel);

run;

Good luck!

Anca.

Ask a Question
Discussion stats
  • 3 replies
  • 459 views
  • 0 likes
  • 3 in conversation