Statalist


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

st: Re: drop command with panel data


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Re: drop command with panel data
Date   Sat, 25 Apr 2009 13:19:09 +0200

<>

Everything rides on your data structure - as always. Let`s pretend you have a long dataset and a dummy indicating the presence of a mortgage at that particular point in time.

***
clear*
set obs 10000
egen float id = seq(), from(1) to(10000) block(8)
egen float time = seq(), from(1) to(8) block(1)
xtset id time

gen byte mortgage =runiform()<0.25

compress
//what does the participation look like?
xtdes

//drop those who do not have a mortgage at any time
bys id:egen anymortgage=max(mortgage)
keep if anymortgage

//what does the participation look like _now_?
xtdes

xttab mortgage
***


HTH
Martin
_______________________
----- Original Message ----- From: <se531@york.ac.uk>
To: <statalist@hsphsun2.harvard.edu>
Sent: Saturday, April 25, 2009 1:07 PM
Subject: st: drop command with panel data


I have a panel of households observed for 8 years, I would like to know how can I drop households that never had a mortgage (e.g.) during the time span.

Thank you in advance,

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