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

st: RE: RE: Using 2 vars to make 1 in presence of missing


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: RE: Using 2 vars to make 1 in presence of missing
Date   Mon, 18 Oct 2004 10:49:59 +0100

Also 

gen c = cond(a == ., b, a) 

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

Maarten Buis
 
> gen c = a
> replace c = b if c==.

SamL 

>  I have two variables, a and b, and 1.5 datasets, A and B.  
> All cases in B are in A, but some cases
> in A are not in B.  I want to merge the two datasets, 
> matching on the id.
> 
> Variable a is missing for some cases in A, but the same 
> variable has valid
> values for some of those cases in B (as b).
> 
> I have tried several approaches.  What I want is:
> 
> do if (a ne .)
> compute c=a
> else if (b ne .)
> compute c=b
> else
> compute c=.
> end if
> 

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