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

st: RE: filling in missing observations in a panel


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: filling in missing observations in a panel
Date   Mon, 19 Dec 2005 21:18:01 -0000

If you have forgotten stuff, the FAQs 
are one repository of solutions. 

Your post implies that you have missings
on -countyid- but not on -county-. 

A very similar question was asked earlier
today and the FAQ cited in that thread 
should be useful to you sometime, if not now. 

In your case, however, it may be that -egen, 
mode()- is your best bet. 

egen idmode = mode(countyid), by(county)
replace countyid = idmode if mi(countyid) 

At some time you need to check that there 
is a one-to-one mapping between -countyid-
and -county-. That is done by 

bysort county (countyid) : assert countyid[1] == countyid[_N]

for reasons complementary to those discussed at
http://www.stata.com/support/faqs/data/diff.html

Nick 
[email protected] 

Scott Cunningham
 
> I have a county-level dataset like the following, which has missing  
> county ID characteristics.
> 
> COUNTY ID | COUNTY | YEAR
> 001                | Lincoln     | 1992
> 001                | Lincoln     | 1993
> .                      | Lincoln     | 1994
> 001                | Lincoln     | 1995
> 
> I need to find all missing observations in the "County ID" column,  
> and replace them with the appropriate value.  I know this is simple,  
> but have forgotten how.

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