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:03:12 -0000 (GMT)

Joseph,

Thanks! I'll try that.

C.

> 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'
> }
>
>
> Joseph Coveney
>
>
>
> Clive Nicholas wrote:
>
> --------------------------------------------------------------------------------
>
> All,
>
> I wondered if you could help with this. I'm sure it's straightforward, but
> I simply cannot hack this!
>
>>From help given in earlier posts, I now have four new variables in my
>> set:
>
> . list part* in 1/20
>
>      +-----------------------------------+
>      | party1   party2   party3   party4 |
>      |-----------------------------------|
>   1. |      l        c        d        n |
>   2. |      l        c        d        n |
>   3. |      l        d        c        n |
>   4. |      l        d        c        n |
>   5. |      l        c        d        n |
>      |-----------------------------------|
>   6. |      l        d        c        n |
>   7. |      l        n        c        d |
>   8. |      l        c        n        d |
>   9. |      l        d        c        n |
>  10. |      l        d        c        n |
>      |-----------------------------------|
>  11. |      l        n        c        d |
>  12. |      l        n        c        d |
>  13. |      c        l        n        d |
>  14. |      c        l        d        n |
>  15. |      c        l        d        n |
>      |-----------------------------------|
>  16. |      l        c        d        n |
>  17. |      c        l        n        d |
>  18. |      l        d        c        n |
>  19. |      c        n        l        d |
>  20. |      c        n        l          |
>      +-----------------------------------+
>
> Although I've successfully converted these into numeric variables, I need
> to convert these letters into _real_ numbers, such that c=1, d=2, l=3 and
> n=4. I'm finding that if this isn't done, I can't perform any analysis
> with them.
>
> Any solutions are greatly appreciated.
>
>
>
> *
> *   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/
>


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