Announcement

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

  • generating new variable

    Hello members,
    Please i want to generate a new variable "marital status" to have categories "1. Maried 2. single 3. Divorced 4. widowed" from the following three variables Var1 (two categories 1. married 2. Not in union) Var2 ( If not in a union, are you( 1. formerly married 2. never married ) Var 3(if formerly married, are you ( 1. Widowed 2.divorced)

  • #2
    The relevant documentation is: 1) -help replace- , 2) -help if qualifier-, and 3) -help operators-.

    The most straightforward approach is to simply follow the conditions you have listed:
    Code:
    gen marstat = 1 if Var1 == 1
    replace marstat = 2 if Var2 == 2
    replace marstat = 3 if Var3 == 2
    replace marstat = 4 if Var3 == 1

    Comment


    • #3
      It's up to you but I suspect that the order

      single / married / divorced / widowed

      would seem less puzzling.

      Comment


      • #4
        i am very grateful @ Mike Lacy and Nick Cox this is very helpful

        Comment

        Working...
        X