Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: proportional random sampling
From
Steve Nakoneshny <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: proportional random sampling
Date
Mon, 24 Oct 2011 17:15:20 -0600
Dear Statalisters,
I have a small dataset (n=44) from which I want to draw a random sample of records. The distribution of these records across my variable of interest in approximately 2:1. What I wish to do is to create a random sample of records of size n that retains the proportional distribution across my variable of interest.
Assuming a random sample where n=12, I wrote the following code:
sort ecs
by ecs: sample 8,count
sample 50 if ecs==1
------
Although how I coded it certainly works, what I am wondering if there is a more elegant means of coding to achieve a similar result?
Thanks,
Steve
*
* 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/