Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Random number seed

Subject   Re: st: Random number seed
Date   Thu, 20 May 2004 15:30:30 +0100

You could use date and time as the seed...
Add the following lines to the start of your program if you are using STATA

tokenize "`c(current_time)'" ,parse(":")
local seed "`1'`3'`5'"
local edate = date("`c(current_date)'","dmy")
local seed "`edate'`seed'"
set seed `seed'


Adrian Mander MSc PhD, Principal Statistician, GlaxoSmithKline, Mail Code
HW8133, New Frontiers Science Park (South), Harlow, Essex, CM19 5AW. Tel:
01279 63 1203 Fax: 01279 64 4677

                      "Subhankar Nayak"                                                                                                        
                      Sent by:                         To:                                                 
                                                       Subject: st: Random number seed                                                         
                      20-May-2004 15:15                                                                                                        
                      Please respond to                                                                                                        

Can the stata random number seed be itself randomized?

I am running a program called "" in the batch mode without
invoking/opening stata. This program carries out an analysis based on a set
of 1,000 uniform random numbers it generates.

However, since the random seed is always the same everytime I run the
program in batch mode, I get the same set of 1,000 random numbers each time
I run this program in batch mode. Results are identical which defeats the

Can this be changed?


*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index