Announcement

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

  • Add lable to binary variable

    Hello.

    I have a binary variable "size" : 1 means it's small, 0 means it's large. But in my data base, it's written : 0 or 1.
    I would like to add a label to 0 and 1. So that in my data, it will be "small" in place of 1. How can I do it ?

    Thank you.

  • #2
    Do you want to replace the dummy with a string variable?
    if yes this will do:

    Code:
    gen size1 ="small" if size==1
    replace size1 ="large" if size==0
    drop size
    rename size1 size

    Comment


    • #3
      you can add value labels to your numeric variable using the label command; there are two steps: "label define" and "label values"; see
      Code:
      help label

      Comment


      • #4
        Code:
        label define sizelbl 0 "large" 1 "small"
        label values size sizelbl
        A better name for that variable would be

        Code:
        rename size small
        Best
        Daniel

        Comment

        Working...
        X