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

st: Stata vs. SAS (random number generation)


From   "Joao Pedro Wagner de Azevedo" <[email protected]>
To   <[email protected]>
Subject   st: Stata vs. SAS (random number generation)
Date   Wed, 6 Apr 2005 18:12:16 -0300

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/



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