proc iml;
call randseed(12345); /* set seed for random number stream */
N = 23; /* number of people in room */
NumRooms = 10; /* number of simulated rooms */
bday = Sample(1:365, NumRooms||N); /* simulate: each column is a room that contains N birthdays */
*print bday; /* optional: print the 23 x 10 matrix of birthdays */
match = N - countunique(bday, "col"); /* number of unique birthdays in each col */
print match[label="Num Matches (N=23)" c=("Rm1":"Rm10")];
/* estimate the probability of a match, based on 10 simulations */
probMatch = (match > 0)[:]; /* mean = proportion of matches */
print probMatch;