I will like to write a code for values of x = (-0.1, 0.0, 0.1)
write code to calculate L (x ; mu = 0, sigma = 1)
In R code(L <-function(x, u=0, s2=1)(sqrt(2*pi*s2))^-1*exp(-(x-u)^2/(2*s2))
x<-c(-0.1,0.0, 0.1)
L(-0.1)
L(0.0)
L(0.1)
Also using
dnorm(-0.1, mean = 0, sd = 1)
dnorm(0.0, mean = 0, sd = 1)
dnorm(0.1, mean = 0, sd = 1)
dnorm(c(-0.1,0.0,0.1),mean = 0, sd = 1)
yield as results in R.
[1] 0.396952547477
[1] 0.398942280401
[1] 0.396952547477
[1] 0.396952547477 0.398942280401 0.396952547477
I want to write equations in either IML or Macro language
proc iml;
do x=-0.1 to 0.1 by 0.1;
y=pdf('normal', x, 0, 1);
print y;
end;
quit;
proc iml;
do x=-0.1 to 0.1 by 0.1;
y=pdf('normal', x, 0, 1);
print y;
end;
quit;
Thanks alot for you helps. The code
proc iml;
do x=-0.1 to 0.1 by 0.1;
y=pdf('normal', x, 0, 1);
print y;
end;
quit;
is similar to using dnorm in R right?
can I also write in IML or macro language the code below?
In R code(L <-function(x, u=0, s2=1)(sqrt(2*pi*s2))^-1*exp(-(x-u)^2/(2*s2))
x<-c(-0.1,0.0, 0.1)
L(-0.1)
L(0.0)
L(0.1)
Thanks alot
Sure. You can. Define a function in IML and @Rick_SAS wrote many blogs about it. and Post it at IML forum since it is a IML question.
Nearly 200 sessions are now available on demand in the Innovate Hub.
Watch Now →SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.