Announcement

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

  • Create Binary Variable

    Hello,

    I have a variable A (=dependent variable) that is encoded 1 to 4, it was measured in 3 consecutive years (2000, 2001, 2002). In 2001, there was an event, and I want to see the effect of this event on A.
    So, I want to create a binary variable (= independent variable = event) where I can see the development of A over time and the effect the binary had on A.
    The binary should be coded 0 (for the year 2000) and 1 (for the year 2002).

    For some reason, I cannot create a binary variable that does that.

    I hope you understand what my problem is. :/ I'm (obviously) very new to Stata and super inexperienced.


    Every help is much appreciated, thank you very much!

  • #2
    what do you want the code to be for the year 2001? I see 3 possibilities here: 0, 1, .(missing)

    Comment


    • #3
      I don't know what I have to do here, to be honest. It probably should be a missing? Because if 2001 is either 0 or 1, I won't be able to compare only 2000 and 2002.

      Comment


      • #4
        here is one way (there are many):
        Code:
        gen byte wanted=1 if year==2002
        replace wanted=0 if year==2000
        note that since there was no data example provided (please read the FAQ), I have made assumptions here including that year is numeric; you should change "wanted" to whatever variable name you actually want here

        Comment

        Working...
        X