Chapter Contents 
Previous 
Next 
CALL RANBIN 
Category:  Random Number 
Syntax  
Arguments  
Details  
Comparisons  
Examples  
See Also 
Syntax 
CALL RANBIN(seed,n,p,x); 
Range:  seed < 2^{31}  1 
Note:  If seed 0, the time of day is used to initialize the seed stream. 
Range:  n > 0 
Range:  0<p<1 
Details 
The CALL RANBIN routine updates seed and returns a variate x that is generated from a binomial distribution with mean np and variance np(1p). If n 50, np 5, or n(1p) 5, SAS uses an inverse transform method applied to a RANUNI uniform variate. If n>50, np>5, and n(1p)>5, SAS uses the normal approximation to the binomial distribution. In that case, the BoxMuller transformation of RANUNI uniform variates is used.
By adjusting the seeds, you can force streams of variates to agree or disagree for some or all of the observations in the same, or in subsequent, DATA steps.
Comparisons 
The CALL RANBIN routine gives greater control of the seed and random number streams than does the RANBIN function.
Examples 
This example uses the CALL RANBIN routine:
options nodate pageno=1 linesize=80 pagesize=60; data case; retain Seed_1 Seed_2 Seed_3 45; n=2000; p=.2; do i=1 to 10; call ranbin(Seed_1,n,p,X1); call ranbin(Seed_2,n,p,X2); X3=ranbin(Seed_3,n,p); if i=5 then do; Seed_2=18; Seed_3=18; end; output; end; run; proc print; id i; var Seed_1Seed_3 X1X3; run;
The RANBIN Example shows the results.
The SAS System 1 i Seed_1 Seed_2 Seed_3 X1 X2 X3 1 1404437564 1404437564 45 385 385 385 2 1445125588 1445125588 45 399 399 399 3 1326029789 1326029789 45 384 384 384 4 1988843719 1988843719 45 421 421 421 5 2137808851 18 18 430 430 430 6 1233028129 991271755 18 392 374 392 7 50049159 1437043694 18 424 384 424 8 802575599 959908645 18 371 383 371 9 100573943 1225034217 18 428 388 428 10 414117170 425626811 18 402 403 402 
Changing Seed_2 for the CALL RANBIN statement, when I=5, forces the stream of the variates for X2 to deviate from the stream of the variates for X1. Changing Seed_3 on the RANBIN function, however, has no effect.
See Also 
Function:

Chapter Contents 
Previous 
Next 
Top of Page 
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.