Wednesday, February 9, 2011

How to draw Normal density in SAS

/* Here we will use function PDF('NORMAL', x, mu, sigma) to get pdf
   More details about this function:
   http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000270634.htm
*/

%let a1=1;
%let b1=1;
%let a2=-1;
%let b2=1;
%let a3=0;
%let b3=1;

data pdf;
      do i=-5 to 5 by 0.02;
   pdf1=pdf('Normal', i, &a1, &b1);
   pdf2=pdf('Normal', i, &a2, &b2);
   pdf3=pdf('Normal', i, &a3, &b3);
   output;
   end;
run;

proc print data=pdf;
run;

goptions reset=all;
symbol1 interpol=j  color=red  width=1  value=none;
symbol2 interpol=j  color=blue width=2  value=none;
symbol3 interpol=j  color=gree width=3  value=none;
axis1   label=(angle=90  'Density'order=(0 to .5 by .1) minor=none;
axis2   label=('i')      order=(-5 to 5 by 1minor=none;;
legend label=none   position=(top right insidemode=share;
proc gplot data=pdf;
      plot   pdf1*i  pdf2*i  pdf3*i /overlay 
                                      vaxis=axis1 
                                      haxis=axis2 
                                      legend=legend;
run;quit;


 

No comments:

Post a Comment