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

From |
George Batchelor <george.batchelor@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Stata vs. SAS (random number generation) |

Date |
Fri, 8 Apr 2005 16:05:38 +0100 |

Surely SPSS and Stata use different random number generators. I believe that when you do not set the seed the number that the program uses is taken from the computer clock. This number is then entered into a random number generator, which unlikely to be the same in both Stata and SPSS. Therefore, although you can set the same seed in both Stata and SPSS, you will never be able to generate the same set of random numbers. You are better off generating the numbers in one program and then inserting them in to the other. George On Apr 6, 2005 10:12 PM, Joao Pedro Wagner de Azevedo <jazevedo@provide.com.br> wrote: > Dear Statalist, > > I would like to know if it is possible, and if so how, to have Stata and SAS > generating the same sequence of random numbers. > > I've tried setting the same seed value in both packages with no success (see > example of the command and output below). > > Any help will be much appreciated. > > Cheers, > > JP > > *************** command *************** > > Stata command > set seed 1 > g z1 = uniform() > set seed 2 > g z2 = uniform() > > SAS command > Z1=UNIFORM(1); > Z2=UNIFORM(2); > > *************** output *************** > > SAS STATA > seed 1 2 seed 1 2 > N Z1 Z2 n z1 z2 > > 1 0.18496 0.97009 1 0.6681852 0.850512 > 2 0.39982 0.2594 2 0.9279611 0.0515642 > 3 0.9216 0.96928 3 0.4844814 0.6303533 > 4 0.54298 0.53169 4 0.469739 0.6991696 > 5 0.04979 0.06657 5 0.9726482 0.518447 > 6 0.81932 0.52387 6 0.5563972 0.3360431 > 7 0.85339 0.06718 7 0.8156933 0.1747266 > 8 0.95702 0.29719 8 0.8364499 0.9104601 > 9 0.27261 0.68993 9 0.5807183 0.3874338 > 10 0.97676 0.22651 10 0.3767964 0.409848 > 11 0.68824 0.41276 11 0.1186234 0.9596469 > 12 0.55855 0.28723 12 0.5055883 0.1529711 > > * > * For searches and help try: > * http://www.stata.com/support/faqs/res/findit.html > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ > * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: Stata vs. SAS (random number generation)***From:*"Joao Pedro Wagner de Azevedo" <jazevedo@provide.com.br>

- Prev by Date:
**st: variable** - Next by Date:
**Re: st: variable** - Previous by thread:
**st: RE: Stata vs. SAS (random number generation)** - Next by thread:
**Re: st: Stata vs. SAS (random number generation)** - Index(es):

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