**RANDMULTINOMIAL()**to simulate a multinomial distribution, and its algorithm derived from binomial distribution was also written as a self-defined IML function which can be used in older SAS versions. However SAS users who have no access to SAS/IML product may need to re-write the function on data-step language or via PROC FCMP. Or, we can tweak PROC SURVEYSELECT for the task by just several rows of simple and straight-forward codes.

First let us specify the parameters of a 4-class multinomial distribution;

data multinomial_dist;

class=1; prob=0.13; output;

class=2; prob=0.07; output;

class=3; prob=0.39; output;

class=4; prob=0.41; output;

run;

The following code simulate a random sample of 10000 trials.

proc surveyselect data=multinomial_dist sampsize=10000 out=sample OUTSIZE outhits method=pps_wr;

size prob;

run;

## No comments:

## Post a Comment