You would need to provide the INPUT data set Portfolio_sim to mean anything.
Since you are using SIM_id as the MEAN of the NORMAL distribution you will have most of your values of the result of the RAND calls close to 2, 3, 4 etc. So pretty much 9 out of 10 of those mean that min(random_PD, 1) are returning 1 so the max(0,1) are returning the 1. And only half of the Sim_id=1 even have a chance of returning a value less than 1.
And then you overwrite the values of the random results so you cannot see that your original values are mostly way larger than 1. Modify these to create new variables to see why you get mostly 1's as results.
/* Constrain to valid ranges */
random_PD = max(0, min(random_PD, 1));
random_LGD = max(0, min(random_LGD, 1));
Do you know what percentage of results of a call such as rand("NORMAL", Sim_PD, 0.01) will have a result withing +/- 0.02 difference from Sim_PD?
Until you understand what the standard deviation is doing to those calls to rand('Normal') (do note the default for Normal is an SD=1) you should be very careful specifying it.
Or better yet, describe what sort of result you expect to be returning as I thing @PaigeMiller is on track.
... View more