Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: recoding strings variables to numerical


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: recoding strings variables to numerical
Date   Sun, 19 Jun 2005 23:57:46 +0100

I don't know why you tried -destring-. This is for 
variables that should be numeric, but just missed being 
read as such. Variables that are all words are the other 
end of the spectrum from that. 

In your case, the answer sounds like -encode-, but create
the labels first. A sensible order given "low" "medium" 
"high" "vhigh" is just that, but -encode- by default just
looks at alphabetical order. 

A more general discussion of the whole string-numeric issue 
was included in Stata Journal 2(3) 2002. 

Nick 
[email protected] 

b. water
 
> stata 8.2. winxp.
> 
> trying to recode string variables (counts) consisting of  
> 'high', 'low', 
> 'medium', 'vhigh', etc to numerical values e.g. high = 1, 
> low=2. look up 
> manuals - recode for numerical only, destring 
> replace/generate did not work. 
> any suggestions or work around? i started with something like 
> gen counts2=. 
> but then i am stuck as to what to do next. would appreciate help.

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