Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: "bsample" and "set seed" together do not work!

From   Daniele Pacifico <>
Subject   Re: st: "bsample" and "set seed" together do not work!
Date   Fri, 17 Sep 2010 14:15:13 +0000 (GMT)

Dear Maarten,
thanks for your help. 
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?

Thanks again for your help,

----- Original Message ----
From: Maarten buis <>
Sent: Fri, 17 September, 2010 14:48:09
Subject: Re: st: "bsample" and "set seed" together do not work!

--- On Fri, 17/9/10, Daniele Pacifico wrote:
> I am working with the command "bsample"  and I
> discovered that the command "set seed #" stops 
> "bsample" from drawing different samples from
> my data.
> I had this problem because I am writing an ado file that
> sets a seed when it runs.. However, I discovered that the 
> seed I define within my ado file creates the problem I
> have shown you above (i.e. I cannot use bsample with the 
> command defined in my ado file).. Do you have any advise
> about it? How can I "unset" the seed so as to allow it to
> vary randomly again with bsample?

"Do not work" does not describe your situation very well: All 
programs work exactly as they should, i.e. they do what you 
told them to do (they may not do what you want them to do, 
but that is a different question).

You might be tempted to set the seed "randomly" inside your
loop before each -bsample- command, but that does not work 
well as Bill discussed here:

I just would avoid setting the seed inside a program. In 
general it sounds like bad practice to me. For one thing
you are this way overwriting any -set seed- commands your
user might issue before your command, thus leaving them
puzzled e.g. when they are trying to run a simulation using 
your command.

Hope this helps,

Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen


*   For searches and help try:


*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index