Announcement

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

  • egen command?

    Can anyone suggest me to do this:

    I need to generate a dummy var3 using var1 and var2.

    Condition: v3=1 if (var1>0 & var1<. ) & (var2>0 & var2<.)

    v3 =0 if out of var1 and var2, exactly one has nonzero (missing value)

    thanks


  • #2
    Code:
    gen byte var3 = cond(var1>0 & var2>0 & !missing(var1) & !missing(var2), 1, cond((var1>0 & missing(var2)) | (var2>0 & missing(var1)),0,.))
    Last edited by Hemanshu Kumar; 03 Nov 2022, 05:36.

    Comment


    • #3
      Thanks Hemanshu.

      Comment


      • #4
        Please cross-reference your other thread when asking two or more versions of the same question. In fact, please ask each question just once.

        Comment


        • #5
          My apologies nick, just started using dataex, so posted twice ( one without, and the other with dataex).

          Comment

          Working...
          X