Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Getting a random sample from panel data


From   "Maarten Buis" <[email protected]>
To   <[email protected]>
Subject   st: RE: Getting a random sample from panel data
Date   Wed, 10 May 2006 20:02:31 +0200

----Christer Thrane wrote:
> In my panel data (one observation per year), the variable lpnr identifies
> persons and the variable aar identifies panels.
>
> I wish to obtain a 10% probability sample that is representative in terms of
> persons (lpnr). But if the person is selected, I want to follow him or her
> throughout the panels (aar).

I usually draw a 10% sample by generating a new variable with random values
from a uniform distribution, and keep those values which got values less than
.1. The trick for you is to give all observations from the same person the same
value for the random variable. This can be done like the example below:

*------------begin example--------------
*assume that rep78 is your lpnr
sysuse auto, clear
tempname uniform
gen `uniform' = uniform()
bysort rep78: replace `uniform' = `uniform'[1]
keep if `uniform' <.1
*----------end example------------------

HTH,
Maarten

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology 
Vrije Universiteit Amsterdam 
Boelelaan 1081 
1081 HV Amsterdam 
The Netherlands

visiting adress:
Buitenveldertselaan 3 (Metropolitan), room Z214 

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------



*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index