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

st: RE: replacement of missing values [was: RE: Help]


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: replacement of missing values [was: RE: Help]
Date   Mon, 7 Mar 2005 17:48:41 -0000

This is equivalent to 

bysort hhid (indicode member) : 
	replace indicode = indicode[1] 
	if mi(indicode) & member == 1

(just one line) 

Nick 
n.j.cox@durham.ac.uk 

Nick Cox
 
> The first non-missing value in each household is 
> 
> bysort hhid (indicode member) : gen firstnonmiss = indicode[1] 
> 
> except that this will return missing if all values
> in any household are missing. 
> 
> so it sounds as if you want to impute like this
> 
> replace indicode = firstnonmiss if mi(indicode) & member == 1 
> 
> I can't see that -collapse- could help here. 
 
Fanwell Kenala Bokosi
  
> > I want to generate a code for the household industry. The 
> > household industry is the industry in which the household 
> > head is engaged in. However for some households where the 
> > industry code is missing for the household head, I want to 
> > assign the next non missing industry code as the for the household.
> > 
> > My data looks like this
> > 
> > hhid member indicode
> > 1         1                 1
> > 1          2                 2
> > 1          3                  3
> > 2           1                  .
> > 2            2                 4
> > 2            3                  4
> > 3            1                   .
> > 3            2                   .
> > 3            3                   1
 

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index