Announcement

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

  • Generating & replacing new variable

    Hi there,

    I have a variable called lop and another variable called age

    I would like to generate a new variable, called age_tied_to_lop, where AGE only has a value if LOP has a value (ie, if LOP = . then I also want my age_tied_to_lop to be coded as missing .)

    I tried the following code, but its not really working:

    gen age_tied_to_lop = .

    replace age_tied_to_lop = age if lop>0

    But I don't want to replace if lop>0; I want to replace only if lop actually has a value (ie, is any value other than .)

    Thanks for any help


  • #2
    since missing is the highest value, it is greater than 0; your code won't do what you want; instead, as your second command, try this
    Code:
    replace age_tied_to_lop = age if lop<.
    you don't really give enough info to know if this is sufficient (please read the FAQ)

    Comment


    • #3
      You may try to use - if !missing(lop) - for that matter.
      Best regards,

      Marcos

      Comment

      Working...
      X