05-26-2013 06:15 PM
if i need to generate random age 10-50 will it really matter if i go by age=round(ranuni(0)*40+10) or age=int(ranuni(0)*50+10);
I mean,do i have to use the INT function when it comes to generating random numbers or it does not matter?
Also,does the seed play a big role here?
05-26-2013 08:46 PM
If you want ages to be whole numbers then you should use function round, int, floor or ceil. To give all ages between 10 and 50 (inclusive) equal probability, use :
age = 10 + floor(41*ranuni(-1));
05-27-2013 12:58 AM
If you check out the RANUNI documentation then it explains what a seed less than 0 does:
In summary a negative seed results in the system time being used instead of the seed so each time you run your program you get a different random number sequence. If you use the same positive seed you will get the same random sequence.
05-28-2013 08:56 AM
See the article How to generate random numbers in SAS - The DO Loop
With regard to the seed, you might also be interested in this article: