Statalist The Stata Listserver


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

Re: st: Replacing several variables at once


From   "Sebastian F. Büchte" <sfbuechte@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Replacing several variables at once
Date   Tue, 6 Feb 2007 13:04:59 +0100

Nuno,

for your special case you could try to use -mvencode- :

mvencode var1 var2 var3, mv(0)

will replace all missing values in var1, var2, var3 by 0. See also
-help mvencode-

A more general approach would be to use recode, see -help recode-

hth
Sebastian


On 2/6/07, Nuno <liststata@gmail.com> wrote:
Hi everyone,

I need to replace missing values by 0 for a set of about 30 variables which
are not sequencially ordered and have very different names. I'm using the
-rename- command for each variable, but this becomes a bit cumbersome and
might contain errors given the number of the variables. Plus, I'll need to
redo the same thing for other datasets. Does anyone know a way of
facilitating this task? I was wondering if -inlist- would be suitable to do
this, as it would only be necessary to define the variables once( something
like replace inlist(arlist)=0 if inlist(varlist)==.).

All the best.

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

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