Statalist The Stata Listserver


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

st: Re: encode string in batch way


From   Kit Baum <baum@bc.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: Re: encode string in batch way
Date   Thu, 21 Sep 2006 07:25:41 -0400


Prefix the command that gives you trouble with capture, and the loop will keep running.

Kit Baum, Boston College Economics
http://ideas.repec.org/e/pba1.html
An Introduction to Modern Econometrics Using Stata:
http://www.stata-press.com/books/imeus.html


On Sep 21, 2006, at 2:33 AM, Jia wrote:


However, you know, there are numerous problems in the file like this,
and I try to encode them a batch way.
label define yesno 0 "N" 1 "Y"
forvalue i=1(1)614 {
encode v`i', gen(vv`i') label(yesno)
drop v`i'
rename vv`i' v`i'
}

Then I was informed
not possible with numeric variable
r(107);
end of do-file
r(107);


Can you help me out? Since there are numerous similar problems,
dealing with them one by one is really annoying.
*
*   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