Hi ... 1st argument is a seed, remaining arguments assign 1, 2, 3, 4, etc with the probability you specify ... a/ probabilities do not sum to 1, RANTBL sums those specified and subtracts them from 1 to get one more assignment rule b/ probability sum > 1, RANTBL adjusts/ignores stated probabilities data test; do _n_ = 1 to 1e5; x = rantbl(0, 0.3, 0.4, 0.25); y = rantbl(0, 0.3, 0.4, 0.25, 0.05); z = rantbl(0, 0.3, 0.4, 0.35, 0.35); output; end; run; Cumulative Cumulative x Frequency Percent Frequency Percent 1 30118 30.12 30118 30.12 2 39952 39.95 70070 70.07 3 24898 24.90 94968 94.97 4 5032 5.03 100000 100.00 Cumulative Cumulative y Frequency Percent Frequency Percent 1 30010 30.01 30010 30.01 2 39996 40.00 70006 70.01 3 25022 25.02 95028 95.03 4 4972 4.97 100000 100.00 Cumulative Cumulative z Frequency Percent Frequency Percent 1 30136 30.14 30136 30.14 2 39908 39.91 70044 70.04 3 29956 29.96 100000 100.00 Another use is to randomly assign a value from an array to a variable ... array names(5) $6 _temporary_ ('mike' 'linlin' 'ksharp' 'art' 'peterc'); name = names(rantbl(0, 0.2, 0.2, 0.2, 0.2)); Cumulative Cumulative name Frequency Percent Frequency Percent art 19869 19.87 19869 19.87 ksharp 19903 19.90 39772 39.77 linlin 20122 20.12 59894 59.89 mike 20089 20.09 79983 79.98 peterc 20017 20.02 100000 100.00 FYI ... there's also CALL RANTBL, and from online doc ... The CALL RANTBL routine gives greater control of the seed and random number streams than does the RANTBL function.
... View more