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

st: RE: Stata vs. SAS (random number generation)


From   "McKenna, Timothy" <Timothy.McKenna@nera.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Stata vs. SAS (random number generation)
Date   Wed, 6 Apr 2005 17:56:45 -0400

In general I don't think you can get SAS and Stata to do this.

A simple, although embarrassingly inelegant, solution would be to have
Stata (or SAS) generate the random numbers.  Then output them to a text
file and have the other program read them in.  You would need to be
careful about precision issues, but otherwise it should work fine.

-Tim

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Joao Pedro
Wagner de Azevedo
Sent: Wednesday, April 06, 2005 5:12 PM
To: statalist@hsphsun2.harvard.edu
Subject: st: Stata vs. SAS (random number generation)

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/ 
  
_____________________________________________________________ 
  
This e-mail and any attachments may be confidential or legally privileged.  If you received this message in error or are not the intended recipient, you should destroy the e-mail message and any attachments or copies, and you are prohibited from retaining, distributing, disclosing or using any information contained herein.  Please inform us of the erroneous delivery by return e-mail.  
  
Thank you for your cooperation. 
  
_____________________________________________________________ 
 

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index