Statalist The Stata Listserver


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

st: Re: MIME-Version: 1.0


From   "Michael Blasnik" <michael.blasnik@verizon.net>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Re: MIME-Version: 1.0
Date   Tue, 20 Feb 2007 09:18:11 -0500

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')
}

Michael Blasnik


----- Original Message ----- From: <jsilberm@sas.upenn.edu>
To: <statalist@hsphsun2.harvard.edu>
Sent: Tuesday, February 20, 2007 8:56 AM
Subject: st: MIME-Version: 1.0



Hi all,

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