Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | "Philip Ryan" <philip.ryan@adelaide.edu.au> |
To | <statalist@hsphsun2.harvard.edu> |
Subject | st: RE: generate random sample |
Date | Mon, 16 Jan 2012 10:24:47 +1030 |
<<>> The following will randomly sample 3 observations on variable x with replacement from 10,000 observations with the distribution you specified. Un-comment the -set seed- line (and provide a numeric seed) if you want reproducibility between runs. see -help bsample- clear * set seed <seednum> input x fw 1 2000 2 1000 3 3000 4 3000 5 1000 end expand fw bsample 3, weight(fw) list x if fw==1 Phil Philip Ryan Professor and Director Data Management & Analysis Centre [DMAC] University of Adelaide -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of ningli_yang@fastmail.fm Sent: Monday, 16 January 2012 9:22 AM To: statalist@hsphsun2.harvard.edu Subject: st: generate random sample Dear listers I am using Stata/MP 11 Windows. What is the good way to generate a sample from a population with replacement? Say, how to generate 3 independent random numbers from population (1,2,3,4,5) with probability distribution (0.2, 0.1, 0.3, 0.3,0.1)? Many thanks for the help. Ning -- Ning Li Survey Methodologist Melbourne Institute of Applied Economic and Social Research The University of Melbourne Tel: +61 3 9035 4949 Fax: +61 3 8344 2111 * * 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/ * * 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/