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

st: RE: Filtering observations.. Urgent HELP

From   "Nick Cox" <>
To   <>
Subject   st: RE: Filtering observations.. Urgent HELP
Date   Mon, 29 Aug 2005 21:46:06 +0100

To get a count of missings in your two variables
you can go 

egen nmiss = rowmiss(dependencia reservas) 


gen nmiss = mi(dependencia) + mi(reservas) 

Observations you want have no missing values. So 
-nmiss- is 0 and you can count such observations

bysort shcode : egen npresent = sum(nmiss == 0) 

Actually, that could all be telescoped into one: 

bysort shcode : egen npresent = sum(!mi(dependencia) + !mi(reservas)) 

Then you are interested in panels for which -npresent > 9-. 

Incidentally, see the advice on claiming urgency at

(This document is cited by the Statalist FAQ.) 


Alonso Viloria
> I am working with Panel data information. I am trying to 
> create a filter 
> to tell me Which individuals have complete information for a set of 
> variables AND just let me know which of them -individuals- 
> have more than 
> certain amount of observations. For example if a have data 
> for 10 years i 
> want stata to tell me which individuals have information of 
> the variables 
> in the same years AND only let me know those individuals that 
> have data 
> for more than 6 years.... Thanks for any pointers in the 
> subject. As you 
> can see i am rather a neophyte in the subject. As far as I 
> have gotten is: 
> by shcode: summarize reservas depeendencia if (reservas~=.) & 
> (dependencia~=.)
> What i want to create is something like:
> by shcode: summarize reservas depeendencia if (reservas~=.) &
> (dependencia~=.) & (Number of Observations or periods in which i find
> both "dependencia" and "reservas" or matching datas are more 
> than 9 periods.

*   For searches and help try:

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