Announcement

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

  • Need help with creating a new variable from existing variable

    Question:

    unemployed = 1 if a person is unemployed, 0 else. Create this variable yourself. Assume that everyone with earnings > 0 is employed.

    Can you please write a code for it? I am quite new to STATA and I need your help!

    generate unemployed=.
    if salary >0 {
    replace unemployed = 0
    }

    else if salary <1 {
    replace unemployed = 1
    }


    this was my code and I know its completely wrong

  • #2
    I'm also quite new. But I think I can help you. The variable you want to create is so called dummy variable. Here is the article how to create it : Stata | FAQ: Creating dummy variables. There is an example there how to create a dummy indicating whether somebody is young or not. Somebody is young if he/she is below 25. Here is the code:

    Code:
    gen young=0
    replace young=1 if age<25
    you can modify this code to your case

    Comment


    • #3
      Okay also kind of new but could this work?
      Code:
      gen unemployed=.
      replace unemployed=0 if salary>0
      replace unemployed=1 if salary<1

      Comment

      Working...
      X