Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Survey data

    Hi,
    I have a basic Stata question. I have survey data.
    I have a variable called EUmember which has 3 possible values: Yes, No, I do not know. I also have missing answers. It is therefore a string variable.
    With which command can I code a value 0 for the answer "No", 1 for the answer "Yes", 2 for the value "I do not know"?
    I tried several avenues which all failed...
    Thanks a lot for your help.
    Have a nice week end!

  • #2
    Code:
    label define EUmember   0   "No"    ///
                            1   "Yes"   ///
                            2   "I do not know"
    encode EUmember, gen(n_EUmember) label(EUmember)
    This will create a new variable, n_EUmember, coded the way you requested. In displays of this variable, you will still see "No", "Yes", and "I do not know", but the actual information in Stata's memory will be the numbers 0, 1, and 2 (and missing values) and you can use this variable in calculations.

    Do read -help label- and the PDF documentation section linked therein. Also, read -help encode-. These commands are very useful in Stata; you will use them frequently.

    Comment

    Working...
    X