[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Running the same do file but getting different results

From   Maarten buis <>
Subject   Re: st: Running the same do file but getting different results
Date   Sat, 9 Feb 2008 20:32:09 +0000 (GMT)

You would get different results each time you run a do-file if your
do-file does something random, e.g. -bootstrap- creates random draws
from your data. From your description I guess that you are doing mostly
data preparation. The only randomness I can think of in that situation
is sorting. When observations are sorted the order of the observations
with the same value are sorted at random. One way to see if a random
number generator is the source of the difference in your runs, so to do
something like this:

set seed 12345

set seed 12345

If the two runs result in the same numbers than you know that at some
point you inadvertantly used random numbers, possibly through -sort-.

Hope this helps,

--- krishanu karmakar <> wrote:

> Dear Statalist and Stata Using Friends,
> I am facing a peculiar problem.
> I am working on a pc with MS Home XP, 1GB Ram and Stata 9.2.
> I am working with a survey data. I have extracted the data from the
> fixed format data files using dictionary files and -infile- command.
> I
> had to merge a few files to reach a consolidated data set.
> Subsequently I have saved this consolidated dataset in the .dta
> format. This is the data set I am working with. I am working with  a
> series of do files so that I need not save the dataset every time I
> make some data modification. I just run all the do files to reach at
> the required stage of analysis.
> i have just noticed the following problem. I start Stata by clicking
> on the .dta file and run the series of do files and get some results.
> Now in the same session of Stata if I use -clear- and then read the
> data set again with -use- command and run the same set of do files I
> get some difference in results. The difference in result is mostly
> noticed for the -count- commands (with some complicated -if-
> conditions). Since the do files are large, I am not printing them in
> this mail. I would appreciate if some of you could throw some light
> on
> the problem if at least from some generic point. I am saying "from
> some generic point" because I can understand that with the above
> information it will be difficult to give a specific solution to my
> problem.
> Any help is deeply appreciated.
> Regards
> Krishanu
> -- 
> Read it:
> Specially Question 3.
> *
> *   For searches and help try:
> *
> *
> *

Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

Sent from Yahoo! Mail - a smarter inbox

*   For searches and help try:

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