Announcement

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

  • dropping multiple missing varibles

    Hello,

    I need to drop rows in a dataset, if all of the 10 variables have missing values at the same time. I am using the following command, but it is saying that (0 observations deleted), which should not be the case. The command is-
    drop if mi( bqarel & bqbwheez & bqbwheezatt & bqbslpwheez & bqbtlkwheez & bqbasth & bqbasthtx & bqbchwhex & bqbdrconi & bqbnose)

    Can someone please help me in this regard? Thanks.

    Fahmida

  • #2
    You may need to have mi() for each variable:

    Code:
    drop if missing(bqarel) & mi(bqbwheez)
    and so on

    Comment


    • #3
      or you can use -egen- with the "rowmiss(varlist)" option; see
      Code:
      help egen

      Comment


      • #4
        Your question is about dropping observations (rows for those with spreadsheet cravings), not variables (columns ditto)

        Rich is right in #3 but Jay is not quite right in #2 as

        Code:
         
         drop if missing(bqarel, bqbwheez)
        is another way to do it.

        Using the operator & is legal here but wrong for your purpose. Logical expressions evaluate to 0 if false and 1 if true and neither 0 nor 1 is missing.

        Code:
        . di 23 & .
        1
        
        . di missing(1)
        0
        
        . di missing(23 & .)
        0
        See also missings, dropobs as introduced in https://www.statalist.org/forums/for...aging-missings

        The search command below gives a clickable link for downloading program files.

        Code:
        . search dm0085_1, sj entry
        
        Search of official help files, FAQs, Examples, SJs, and STBs
        
        SJ-17-3 dm0085_1  . . . . . . . . . . . . . . . . Software update for missings
                (help missings if installed)  . . . . . . . . . . . . . . .  N. J. Cox
                Q3/17   SJ 17(3):779
                identify() and sort options have been added

        Comment


        • #5
          Thanks

          Comment

          Working...
          X