Statalist


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

Re: st: AW: AW: AW: Keep subsequent observations in panel data


From   Nikolaos Kanellopoulos <nkkanel@yahoo.gr>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: AW: AW: AW: Keep subsequent observations in panel data
Date   Mon, 5 Oct 2009 16:27:22 +0000 (GMT)

Nick, Martin and Austin,

thanks for the answer and the guidelines provided.

Nikos




----- Original Message ----
From: Martin Weiss <martin.weiss1@gmx.de>
To: statalist@hsphsun2.harvard.edu
Sent: Monday, October 5, 2009 6:14:24 PM
Subject: st: AW: AW: AW: Keep subsequent observations in panel data


<> 

The basis for all out acrobatic maneuvers with your seemingly simple problem is -as always- Nick`s http://www.stata-journal.com/sjpdf.html?articlenum=pr0004




HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Martin Weiss
Gesendet: Montag, 5. Oktober 2009 17:11
An: statalist@hsphsun2.harvard.edu
Betreff: st: AW: AW: Keep subsequent observations in panel data


<> 

The second one could be as easy (LOL) as



*************
clear*

inp byte(i t y)
1      1     0 
1      2     0 
1      5     0 
1      6     0 
1      7     0 
1      8     0 
2      2     0 
2      5     0 
2      6     0 
2      7     0 
2      8     0 
end

compress

bys i: keep if  /* 
*/ sum((t-t[_n-1])>1)<=1
*************

although you want to check this carefully...


HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Martin Weiss
Gesendet: Montag, 5. Oktober 2009 16:58
An: statalist@hsphsun2.harvard.edu
Betreff: st: AW: Keep subsequent observations in panel data


<> 

The first case should be as easy as


*************
clear*

inp byte(i) t y 
1      1     0 
1      2     0 
1      5     0 
1      6     0 
1      7     0 
1      8     0 
2      2     0 
2      5     0 
2      6     0 
2      7     0 
2      8     0 
end

compress

bys i:gen spell=_n
keep if t==spell
l, noobs sepby(i)

*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Nikolaos Kanellopoulos
Gesendet: Montag, 5. Oktober 2009 16:28
An: statalist@hsphsun2.harvard.edu
Betreff: st: Keep subsequent observations in panel data

Dear all,

I have a very simple unbalanced panel, where individuals are allowed to drop in and out of the sample. I want to create two separate datasets with  the following sampling criteria.

For the first one, individuals  that appear in the first wave should remain in the sample at subsequent years until the first time they drop out of the panel,
either completely or not. If they rejoin the panel later these observations should not be used. For instance in the following example I want to keep only observations 129 and 130.

+----------------------+
i   t   y 
----------------------
129.  1      1     0 
130.  1      2     0 
133.  1      5     0 
134.  1      6     0 
135.  1      7     0 
136.  1      8     0 
+----------------------+
137.  2      2     0 
138.  2      5     0 
139.  2      6     0 
140.  2      7     0 
141.  2      8     0 
+----------------------+

For the second dataset individuals should remain in the sample at subsequent years from the first time they are observed until the first time they drop out of the panel, either completely or return again. Again , if they rejoin the panel later these observations should not be used. For instance in the following example I want to keep only observations 129 to 130 and 137.

+----------------------+
i   t   y 
----------------------
129.  1      1     0 
130.  1      2     0 
133.  1      5     0 
134.  1      6     0 
135.  1      7     0 
136.  1      8     0 
+----------------------+
137.  2      2     0 
138.  2      5     0 
139.  2      6     0 
140.  2      7     0 
141.  2      8     0 
+----------------------+


Thanks 
Nikos



      
___________________________________________________________ 
Χρησιμοποιείτε Yahoo!; 
Βαρεθήκατε τα ενοχλητικά μηνύματα (spam); Το Yahoo! Mail 
διαθέτει την καλύτερη δυνατή προστασία κατά των ενοχλητικών 
μηνυμάτων http://login.yahoo.com/config/mail?.intl=gr 


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


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



      
___________________________________________________________ 
Χρησιμοποιείτε Yahoo!; 
Βαρεθήκατε τα ενοχλητικά μηνύματα (spam); Το Yahoo! Mail 
διαθέτει την καλύτερη δυνατή προστασία κατά των ενοχλητικών 
μηνυμάτων http://login.yahoo.com/config/mail?.intl=gr 


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