Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Sample with weights


From   "Svend Juul" <SJ@SOCI.AU.DK>
To   <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Sample with weights
Date   Fri, 30 Sep 2005 20:00:40 +0200

Willard wrote:
I have a population of company's. I want a sample from this population,
but the probability of a company to be sampled has to be equivalent with
the number of employees (let's call this "size").
----

There may be smarter ways than this. Here I assume that you have 100 companies with 1 to 100 employees:

------------------------------------------------------------------
// generate 100 companies with 1-100 employees
clear
set obs 100
gen company=_n
set seed 123456
gen size=int(100*uniform())+1

// expand with number of employees
expand size

// We want 10 companies; sample 15 to allow for duplicates
sample 15 , count

// drop duplicates from the sample
sort company
drop if company==company[_n-1]

// sample 10 companies
sample 10 , count
------------------------------------------------------------------

Does this do what you want?

Svend

________________________________________________________

Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6
DK-8000 Aarhus C,  Denmark
Phone, work:  +45 8942 6090
Phone, home:  +45 8693 7796
Fax:          +45 8613 1580
E-mail:       sj@soci.au.dk
_________________________________________________________

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index