/*NORMINV of Random Binomial Probability of Default*/
%let N = 10;
%let M= 3;
proc iml;
call randseed(123);
x = j(&N,&M);
cdf=j(&N,&M);
q=j(&N,&M);
p = {.100 .200 .500};
p_mat = repeat(p, &N);
stdev_mat=p_mat#(1-p_mat);
N_mat = repeat(&N, &N, &M);
call randgen(x, "Binomial", p_mat, N_mat);
x=x/&N;/*Random probability of default*/
q = quantile("Normal", x, p_mat, stdev_mat); /*Quantile of the probability
from normal distribution (Distance to default)*/
mean=mean(x);
max=x[<>,];
min=x[><,];
print p,mean,max,min,x,q;
Quit; Hi Rick_SAS, I have refined the code with your help and now I am passing on a matrix of probabilities to the function using the formula you suggested. However, I am getting an error on Quantile function again i.e. ERROR: (execution) Invalid argument to function. Just to give you some background: I am trying to generate random variables using the mean probability of default ( matrix x) and then want to calculate distance to default by finding the quantile ( matrix q) assuming normal distribution. Thanks for your help in advance.
... View more