Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: "bsample" and "set seed" together do not work!
From
Maarten buis <[email protected]>
To
[email protected]
Subject
Re: st: "bsample" and "set seed" together do not work!
Date
Fri, 17 Sep 2010 14:42:15 +0000 (GMT)
--- On Fri, 17/9/10, Daniele Pacifico wrote:
> Well, I actually need to set the seed inside my program..
> In your opinion, is there a way to create a "temporary
> seed" within a ado file? I mean, something like a
> temporary variable that disappears once the program
> ends?
I still don't think that this is the best way of doing
what you want to do. Setting seeds inside general use
programs still seems like bad practice, so I strongly
recommend that you rethink this (or tell us why you
think this is necesary, so we can think about it).
Having said that, the current state of the seed can be
recovered using c(seed), so you can store that in a
local and than set the seed to some constant, do your
stuff under the constant seed, and than set the seed
to the current state to continue where you where
before you moved to the constant seed.
*------------ begin example -----------------
local seed `c(seed)'
forvalues is = 1/5 {
set seed `seed'
di "should change: " runiform()
local seed `c(seed)'
set seed 12345
di "should be constant: " runiform()
di _n
}
*-------------- end example ------------------
Hope this helps,
Maarten
--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany
http://www.maartenbuis.nl
--------------------------
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/