This post was kindly contributed by SAS Programming for Data Mining Applications - go there to comment and to read the full post. |
Today, Rick (blog @ here) wrote an article about random number seed in SAS to be used in random number functions in DATA Step. Rick noticed when multiple random number functions are called using different seeds, only the first one matters.
This is so true. In fact, SAS Manual also has a comprehensive writting on this issue, namely, how to control seeds for each iteration of the random number generation process and how to generatie multiple statistically independent streams of random numbers, see here. In fact, sasCommunity.org also has an article about this issue, see here.
To echo Rick’s post, there is a way to control the seed so that NOT only the first one matters: use CALL routines which by theory will generate computationally independent random number sequence. But if the two seeds are too close, the generated sequences may not be statistically independent. Again, refer to the SAS manual for details.
data normal;
seed1 = 11111;
seed2 = 22222;
seed3 = 383333;
do i = 1 to 1000;
call rannor(seed1, x1);
call rannor(seed2, x2);
call rannor(seed3, x3);
x4=rannor(seed2);
x5=rannor(seed3);
output;
end;
run;
proc sgscatter data=normal;
matrix x1-x5/ markerattrs = (size = 1);
run;
This post was kindly contributed by SAS Programming for Data Mining Applications - go there to comment and to read the full post. |