Announcement

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

  • Replacing many year variables quickly

    Hi,

    I am trying to merge together 2 variables using the replace function. I have data for year of birth for all the countries in my dataset but for Ethiopia, it is listed as a separate variable.

    So far I have tried doing:
    Code:
    replace birthyear = 1947 if birthyear_et == 1947 
    replace birthyear = 1948 if birthyear_et == 1948 
    replace birthyear = 1949 if birthyear_et == 1949
    etc
    But is there an easier way to do this as the years go upto 2003 so this could take a while

    Thank you

  • #2
    Code:
    help forval

    Comment


    • #3
      Sounds like

      Code:
      replace birthyear = birthyear_et if birthyear_et < ,

      Comment


      • #4
        I think Nick means for the final character in the code he shows to be . and not ,

        Comment


        • #5
          Clyde Schechter is totally correct.

          Comment


          • #6
            Thank you for your help Nick and Clyde that has worked perfectly

            Comment

            Working...
            X