Statalist


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

st: Re: Random subset from existing panel dataset


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Re: Random subset from existing panel dataset
Date   Fri, 3 Jul 2009 20:06:08 +0200

<>
**********
clear*
set obs 100

//id
gen id=_n

//expand to # of time periods
expand 10

//time var
bys id: gen time=_n

compress

//unbalanced
drop if runiform()<0.1

xtset id time
xtdes

//sample 10% w/o regard to units
preserve
sample 10
restore

//sample 10% of panel units
gen x=runiform()

bys id: keep if x[1]>0.9
drop x

**********


HTH
Martin
_______________________
----- Original Message ----- From: <frauke.ruether@unisg.ch>
To: <statalist@hsphsun2.harvard.edu>
Sent: Friday, July 03, 2009 6:28 PM
Subject: st: Random subset from existing panel dataset


Dear statalist,

I would like to do something that is pretty straight forward, but I do not
have the stata skills to do this and would appreciate some help.

I have an unbalanced panel data set (almost 101.000 observations) which is
too large to work with. The dataset looks like:

Id      year     y(dependent variable)  x1      x2      x3 (many many
covariats)
1       2000
1       2001
1       2002

2       2003
2       2004

3       1998
3       1999
3       2000
3       2001
3       2002
3       2003
3       2004
3       2005

The dataset is already xtset with identifier (ID) and time (year). Because
the original dataset is too large I would like to take a random subsample
(containing of ca. 1000 observation) out of the original dataset. I have
already tried to follow the advices from the FAQ "How can I take random
samples from an existing dataset?", but it does not work for me.

Does somebody could help me to solve this problem?

Best regards

Frauke


___________________________________

Frauke Rüther, Dipl.-Kffr., M.A.
Research Associate
University of St.Gallen
Institute of Technology Management
Dufourstrasse 40a
CH - 9000 St. Gallen

Phone   +41 (0)71 224 7225
Fax        +41 (0)71 224 7301
Email    frauke.ruether@unisg.ch
Web      www.item.unisg.ch

*
*   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/


*
*   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/



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