Data visualization with SAS programming

How to draw a standard normal denstity curve

Reply
Contributor
Posts: 49

How to draw a standard normal denstity curve

Hi all,

I was trying to draw a standard normal density curve using probnorm function. But instead of curvy it is spiky around zero. So is there any way to do it?

Thank you,
Lu
Super User
Posts: 11,101

Re: How to draw a standard normal denstity curve

It might help to show what you've attempted.
Contributor
Posts: 49

Re: How to draw a standard normal denstity curve

This is the code I used. It only generate the standard normal pdf alone, which is what i want. But you can see it is spiky instead of curvy around zero. Do you know it there better way to do it?

data try;
do z = -5 to 5 by 0.001;
if z gt 0 then pdf = 1- probnorm(z);
else pdf = probnorm(z);
output;
end;
run;

proc gplot data=try;
plot pdf*z ;
run;

Many thanks,
Lu
Regular Contributor
Posts: 165

Re: How to draw a standard normal denstity curve

The probnorm function returns the CDF, try using pdf('normal',z).

Good luck!
Contributor
Posts: 49

Re: How to draw a standard normal denstity curve

I am sorry I don't get it. Is there a function that return the pdf? Thanks.
Contributor
Posts: 49

Re: How to draw a standard normal denstity curve

Sorry I just figured it out. It gives the perfect curves as I thought to be.
Thanks you very much!
Lu
Super User
Posts: 9,854

Re: How to draw a standard normal denstity curve

how about it:
[pre]
data normal;
do i=1 to 10000 ;
normal=rand('normal',0,1);
output;
end;
run;
proc univariate data=normal ;
histogram normal/normal;
run;
[/pre]


Ksharp
Contributor
Posts: 49

Re: How to draw a standard normal denstity curve

Thanks. But I only want to have the standard normal pdf alone. Do you know if there is better way to do it. Below is my original code:

data try;
do z = -5 to 5 by 0.001;
if z gt 0 then pdf = 1- probnorm(z);
else pdf = probnorm(z);
output;
end;
run;

proc gplot data=try;
plot pdf*z ;
run;

Many thanks,
Lu
Ask a Question
Discussion stats
  • 7 replies
  • 548 views
  • 0 likes
  • 4 in conversation