Hi,
I have a 3x3 character array which I want to populate with random occurences of the characters A, B or C. To do this, I created a parrallel 3x3 nuemeric array and withing each (i,j) element of that array I want to randomly generate a number form the uniform distributiom. If that number if within the first third, then the corresponding element of the character array is A etc.
Here is the code:
proc iml;
schedule = j(3,3," ");
random_numbers=j(3,3,.);
print schedule;
print random_numbers;
do i = 1 to 3;
do j = 1 to 3;
call randgen(random_numbers[i,j],"uniform");
if random_numbers[i,j] <= 1/3 then schedule[i,j] = "A";
if 1/3 < random_numbers[i,j] <= 2/3 then schedule[i,j] = "B";
if 2/3 <random_numbers[i,j] <= 1 then schedule[i,j] = "C";
end;
end;
print schedule;
quit;
But as a result all of the character array's elements are C...
Thanks!
... View more