Announcement

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

  • Renaming values of string variables using conditions

    Hi all,

    I am very new to STATA and unfortunately working on a deadline to submit a cleaned dataset.

    Can someone please help me with the following?

    I have three variables of interest. Day the observation is collected (start_day), location incorrectly entered (location) and correct locations (location2).

    For example I would like to replace all observations with "london" under variable location WITH "durban" under new variable location2 IF the day was 18

    I have looked on the STATA help section and all over the internet but haven't been able to find a solution.

  • #2
    It seems unlikely that anyone would have had this precise problem before.

    Code:
    help replace
    gives pertinent examples.

    Code:
    replace location2 = "durban" if location == "london" & start_day == 18

    Comment


    • #3
      Thank you so much, Nick! That worked perfectly. Your help is indeed much appreciated.

      Comment

      Working...
      X