hi friends ,
we are trying to generate a random number between 1, 2 and 3. the issue we are facing is that every time we open the CSPro file again, it generates the number 2 every time. Though when we add cases in the same file, then it generates random number. I have tried using both random(1,3) and randomin(1,2,3) but am still facing the same issue.
Would appreciate if some one can help me on this issue.
Thanks in Advance!!
Issue in Random number generation()
-
josh
- Posts: 2403
- Joined: May 5th, 2014, 12:49 pm
- Location: Washington DC
Re: Issue in Random number generation()
To generate different sequences of random numbers each time you run you need to seed the random number generator with a value that will be different each time the application is run. I would recommend using the system time as a seed value. Seed the random number generator once at the start of the program such as in the preproc of the FF. Something like this:
PROC SURVEY_FF
preproc
// Seed random number generator with current time
seed(systime());
PROC SURVEY_FF
preproc
// Seed random number generator with current time
seed(systime());