Announcement

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

  • How to make exclusion-group from several variables?

    Hello!
    I am new to STATA, so this is definitely a question regarding user error, and may seem trivial.
    I want to group together several variables, and only include ID:s if the have a value in each of those variables. In other words I'm trying to make an exclusion of ID:s that are missing data in any of the variables.
    I have tried to do this in several ways, for example:
    gen group =1 if varname1 <. & varname2 <. & varname3 <.

    Have a nice day!
    //Lars

  • #2
    Well if you want to eliminate all observations that have a missing value for varname1, varname2, or varname 3, the simplest way is just
    Code:
    keep if !missing(varname1, varname2, varname3)
    If you don't want to eliminate the variables, but just mark them for exclusion from later calculations, you can do that with
    Code:
    gen byte exclude = missing(varname1, varname2, varname3)
    ...
    whatever if !exclude
    I should point out, however, that this may be unnecessary. Most Stata commands will automatically exclude any observations that has a missing value for any variable that is mentioned in the command.

    Comment


    • #3
      Thank you!
      This helped a lot. Have a great weekend!
      //Lars

      Comment

      Working...
      X