Announcement

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

  • Recoding All Binary Variables

    Hi,

    I am new to STATA. All the binary variables in my dataset are coded such that 1 is a "yes" and 2 is a "No" and I wanted to recode all variables such that 1 is a "yes" and 0 a "No." How do I do that to all the binary variables in the dataset? Will I have to construct loops?

  • #2
    No, this can be done in a single line, with no loops.

    Code:
    recode var1 var2 var3 var4 /*etc.*/ (2 = 0)
    Replace var1 var2 var3 var4 by the actual complete list of names of the variables you need to change.

    Comment


    • #3
      To Clyde's solution let me add that perhaps the output of help varlist will show you ways of reducing the amount of typing to prepare your list of variables using "wildcards" and similar constructs.

      Comment


      • #4
        Thank you Clyde and William.

        Comment

        Working...
        X