Statalist


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

st: generating random numbers from a specified list


From   Jochen Sp�th <[email protected]>
To   <[email protected]>
Subject   st: generating random numbers from a specified list
Date   Fri, 15 Aug 2008 17:20:34 +0200

Dear statalisters,

trying to build up a new dataset which is (almost) entirely random I'm confronted with the following problem: How can I tell Stata to generate a variable by randomly picking  numbers from a (previously) specified list? Here's a minimal example of what I want to do:


Data right looks like follows:

firm	year  az_ges  az_ges_vz
1000129	1975	15	11
1000129	1976	14	11
1000129	1977	8	6
1000129	1978	26	20

1000530	1993	12	9
1000530	1994	29	22
1000530	1995	26	20
1000530	1996	14	11
1000530	1997	18	14

and so on, where firm is the cross section identifier and year the time variable. Note that data ist organised in long format.
Now, I'd like to add a variable which contains for each firm a number picked at random from a specified list, f.i. list=(10000,10005,10010, and so on). This "random" number should be the same for firms across years. The list exists already, albeit in a separate data file that can't be merged with the data set at hand because it lacks the identifiers betnr and year.

Any suggestions?

Thanks,

Jochen

-------------------------------------------------------------------------------------------

Jochen Sp�th
Dipl.-Volkswirt
Institut f�r Angewandte Wirtschaftsforschung (IAW) T�bingen
Ob dem Himmelreich 1
72074 T�bingen
Tel.: +49-(0)7071-9896-14
Fax: +49-(0)7071-9896-99
EMail: [email protected]
IAW-Homepage: www.iaw.edu

-------------------------------------------------------------------------------------------



*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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