Announcement

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

  • Combining multiple dummy variables into one dummy variable

    HI,
    I'm trying to create variable wave (values 1-13) based on whether people were interviewed at each year (0,1). There are 13 variables so AIWWAVE is 1992 data on yes/no interview that year. HOw do I use if then statements correctly?

    generate wave = 1 if AIWWAVE==1 else == 0
    replace wave = 0 if BIWWAVE== 1 then wave ==2


  • #2
    Code:
    gen wave=(AIWWAVE==1)  /* creates an indicator with value 1 when AIWWAVE==1 and 0 otherwise */
    replace wave=2 if BIWWAVE==1
    It looks like you would probably benefit from taking a step back and making sure you understand basic Stata syntax. I highly recommend reading Getting Started with Stata (it's available as a pdf with your install).

    Code:
    help gs
    That should take you to a page with a table of contents and links to the pdf.

    This Stata FAQ also has some helpful info on creating variables https://www.stata.com/support/faqs/d...mmy-variables/

    Comment

    Working...
    X