Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Re: MIME-Version: 1.0


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Re: MIME-Version: 1.0
Date   Tue, 20 Feb 2007 21:04:59 -0000

Na�v� -- or even na�ve -- or not, there is at least
one answer not yet given. The -max()- function and 
-egen, rowmax()- will both yield the single non-missing
value whenever just one value is non-missing and the others
are all missing (of whatever flavour) and all are numeric. 

Nick 
[email protected] 

Michael Blasnik
 
> It will be easy to do in Stata (no cutting or pasting) but 
> the best answer 
> may depend on what these variables are named, whether they 
> are string or 
> numeric, and whether the ones to ignore contain missing 
> values or something 
> else.  Here are some examples:
> 
> * strings, all blank but one, easy to just concatenate:
> gen mystring=string1+string2+string3+string4
> 
> * numeric var, all missing but one
> gen mynumvar=.
> foreach var of varlist numvar1 numvar2 numvar3 {
>     replace mynumvar=`var' if !missing(`var')
> }

[email protected]

> > I have a single variable that was erroneously split into several 
> > variables, and
> > I need to re-merge many variables into a single variable.
> >
> > Within any single observation, just 1 of the variables to 
> be merged has 
> > data in
> > it, and I need to get the data from all of the variables 
> into a single
> > variable.
> >
> > Short of lots of cutting and pasting, does anybody know 
> exactly how to do 
> > this?
> >
> > Apologies if this is a na�v� question; I'm a Stata novice.

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