Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Olga Gorbachev <olga.gorbachev@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

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/

**Follow-Ups**:**Re: st: random samples within each of 1,152 categories***From:*Steve Samuels <sjsamuels@gmail.com>

**Re: st: random samples within each of 1,152 categories***From:*Maarten Buis <maartenlbuis@gmail.com>

- Prev by Date:
**st: Importing Data and Defining Variable Types** - Next by Date:
**Re: st: Differebnce-in-Difference and Stata** - Previous by thread:
**st: Importing Data and Defining Variable Types** - Next by thread:
**Re: st: random samples within each of 1,152 categories** - Index(es):