Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Recoding all variables in a dataset


From   Ryan Kessler <ryan.kessler.stata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Recoding all variables in a dataset
Date   Fri, 23 Nov 2012 12:34:30 -0500

sysuse auto, clear
foreach x of varlist * {
	if substr("`: type `x''",1,3) != "str" {
		recode `x' (23 = 88888)
	}
}
// This is easier when we don't have any string variables in the dataset
drop make
recode * (24 = 99999)

On Fri, Nov 23, 2012 at 12:19 PM, Stephen Cranney
<scranney@sas.upenn.edu> wrote:
> Hi all,
>
> Pardon the simple question, but I haven't been able to find an answer.
> Is there a quick and parsimonious way to refer to all the variables in
> a dataset for purposes of recoding?
>
> Thanks in advance,
>
> Stephen
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index