Announcement

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

  • #16
    Sorry about the mangled script in the previous.

    Code:
    log using choonjo_problems.log
    
    set more off
    
    display "Stata " c(stata_version)
    foreach cmd in findname missings {
        which `cmd'
    }
    
    * 2. missings breakdown: error r(3000) when missing values occur only in strings.
    *    Numeric variables can be present, provided none of them has a missing value.
    clear
    input byte id str1 s
    1 "a"
    2 ""
    end
    capture noisily missings breakdown
    local bd_rc = _rc
    display "missings breakdown: rc=`bd_rc'"
    assert `bd_rc' == 3000
    * capture noisily displays the expected error and lets the remaining examples run.
    * In actual checks, do not ignore an error and interpret it as "no missing values".
    
    * 3. Recommended: findname for a variable list; missings report for counts.
    *    missing() detects numeric . and .a-.z, and the empty string "".
    findname _all, any(missing(@))
    local mvars "`r(varlist)'"
    display "Variables with missing values: `mvars'"
    assert "`mvars'" == "s"
    missings report
    assert "`r(varlist)'" == "s"
    
    log close

    Comment


    • #17
      The bug in missings has been fixed. A Software Update will be submitted to the Stata Journal. Thanks again to Choonjoo Lee for reporting this bug.

      If missing values occurred only in string variables, then the count of numeric levels that are missing should be set to 0 as in the command

      Code:
      else local nlevels = 0
      added to the block cited here.

      Code:
      quietly if `numhere' | "`seeallzeros'" != "" { 
                  if "`sysmiss'" != "" local levels . 
      
                  else {
                      foreach v of local misslist {
                          levelsof `v' if missing(`v') & `touse', missing clean local(this) 
                          local levels `levels'  `this' 
                      } 
                      local levels : list uniq levels 
                      local levels : list sort levels 
                      
                      if "`levels'" == "" & "`seeallzeros'" != "" local levels . 
                  } 
      
                  local nlevels : list sizeof levels
      } 
      else local nlevels = 0
      Last edited by Nick Cox; Yesterday, 15:54.

      Comment


      • #18
        Thank you, Nick. I'm glad my observation was helpful, even if I stumbled upon it almost by accident!

        My background is not in software development, and I've learned Stata programming largely through trial and error. Handling missing values and variables was one of the many challenges I encountered along the way.

        I'm pleased that sharing one of those experiences helped identify a bug. Thanks for fixing it!

        Comment


        • #19
          Thank you again for the fix. Could you also check the following example against your revised version? With sysmiss, I would expect both commands to report one missing value. In the currently available version, missings report gives 1, but missings breakdown shows 3 under “# missing” and 1 under “.”. This may be a separate issue in how the total is calculated.

          Code:
          clear
          input double x
          .
          .a
          .z
          1
          end
          
          * Both commands should count only the single system missing value (.).
          missings report x, sysmiss
          missings breakdown x, sysmiss
          Thanks a lot!

          Comment


          • #20
            Correct again and many thanks. I will add the fix to the code.

            Comment

            Working...
            X