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

Re: st: Converting letters to numbers


From   "Clive Nicholas" <[email protected]>
To   [email protected]
Subject   Re: st: Converting letters to numbers
Date   Wed, 28 Jan 2004 00:42:56 -0000 (GMT)

Joseph Coveney wrote:

> How about something like this?
>
> label define Parties 1 c 2 d 3 l 4 n
> forvalues i = 1/4 {
>     encode party`i', generate(Party`i') label(Parties)
>     drop party`i'
>     rename Party`i' party`i'
> }

OK, it ran, but the end-result still displays letters rather than the
numeric (and real) values I want them to represent.

I should be a bit more specific in explaining what I've tried to overcome
this difficulty (I'm on v8.2). I've used -encode-, as in

. encode party1, gen(winner)

but this merely produced variables with the same characters. Stata won't
accept a simple -recode- such as

. recode party c=1

Michael Blasnik did suggest -subinstr-, but I couldn't work out how to
action this command. Every time I tried it, including

. subinstr(c,l,d,1,2,3)

I kept getting an 'unrecognized command' error (oddly). There has to be a
simple solution to this simple problem!

CLIVE NICHOLAS        |t: 0(44)191 222 5969
Politics Building     |e: [email protected]
School of Geography,  |f: 0(44)870 126 2421
 Politics & Sociology |
University of         |
 Newcastle-upon-Tyne  |
Newcastle-upon-Tyne   |
NE1 7RU		      |
United Kingdom	      |http://www.ncl.ac.uk/geps
*
*   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