Announcement

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

  • Generate three dummy variables

    Hi Scholars,

    I need to create 3 dummies from one specific variable, for example,

    gen d.var=1 if variable>0
    replace d.var=-1 if variable<0
    replace d.var=0 if variable=0

    Here, I need to create d.var=0 if variable=0; however, the last Stata code is not working. Would you please help me to generate three dummies like this?

  • #2
    I see only a single variable being generated.
    Code:
    generate byte d_var = sign(variable) if !mi(variable)
    help sign()
    You can then use tabulate . . . , generate() to create three indicator variables from d_var.

    Comment

    Working...
    X