Bookmark and Share

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: random samples within each of 1,152 categories


From   Olga Gorbachev <[email protected]>
To   [email protected]
Subject   st: random samples within each of 1,152 categories
Date   Tue, 7 May 2013 21:18:09 -0400

Hello,

I need to generate random samples for 1,152 categories and I am not
sure how to do it.

To be specific:

for each cell, I need to compute a fraction of not working females.  I
generated the needed fraction (swr), like this:

bys year ed white nokid wife: gen w=(work==0 & rlinc!=.)
bys year ed white nokid wife: egen sw=sum(w)
bys year ed white nokid wife: gen swr=100*sw/_N

Thus, swr gives me the percent of nonworking females within each cell.

I then  generated categories/cells using group command:

egen x=group(ed wife nokid white year)

this gave me 1,152 groups.

Thus, for each x I have a number given by swr that tells me what
percentage I want to sample. So for x=1, swr=43.2

Thus, I'd like to 'designate' randomly for x=1 if work=1 43.2% of
females to be not working. And I'd like to do this for each x.
Ultimately, I'll need to sample with weights.

I tried using gsample, but was unable to figure out the syntax for the
looping that I think I'll need to do for this problem.

Thank you in advance for your help.

--
Olga Gorbachev
Assistant Professor of Economics
University of Delaware
Newark, DE 19716
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index