Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | "Seed, Paul" <paul.seed@kcl.ac.uk> |
To | "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |
Subject | Re: st: inconsistent random numbers even using -set seed- |
Date | Fri, 31 Jan 2014 14:38:46 +0000 |
Thank you also to Phil Schumm. (and Bill Gould for the original post that Phil links to). That answers my second question. -isid- is useful command that I have not come across before. For those who don't know, it checks whether the specified variables uniquely identify the observations; and with the -sort- option carries out a genuinely unique sort. I suppose the ideal code for my example is now *************************** * Example code showing solution 2* version 11.2 set more off sysuse auto, clear bys rep78: su price mpg * Crucial change here isid make, sort set seed 1234 gen rand = runiform() bys rep78 (rand) : keep if _n <= _N/2 bys rep78: su price mpg * End example * *********************** Paul T Seed, Senior Lecturer in Medical Statistics, Division of Women's Health, King's College London Women's Health Academic Centre, King's Health Partners (+44) (0) 20 7188 3642. * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/